يعالج المعالج الموضح هنا عمليات الاسترجاعات من خدمة GrabzIt screenshot على الويب. يتم تمرير عنوان URL لهذا المعالج إلى GrabzIt في callBackURL
المعلمة من Save الأسلوب.
ومع ذلك ، ستعمل هذه التقنية فقط إذا كان المعالج يمكن الوصول إليه عبر Internet.
يتم تمرير المعلمات التالية إلى المعالج كمعلمات GET.
إذا كنت ترغب في حظر كل الوصول إلى المعالج ، باستثناء GrabzIt ، فاستخدم هذا تقنية الأمان.
يوضح هذا المثال كيف يمكن تنفيذ معالج GrabzIt Python. يلتقط هذا ستة معلمات تم تمريرها إليها من خدمة GrabzIt، بما في ذلك المعرف الفريد للقطة الشاشة التي تم تمريرها إلى GetResult الأسلوب.
هذه الطريقة ثم إرجاع لقطة الشاشة ، وهو saveد في دليل النتائج. ولكن إذا أ null
يتم إرجاع القيمة من GetResult تشير هذه الطريقة إلى حدوث خطأ.
import os import cgi from GrabzIt import GrabzItClient from ConfigParser import SafeConfigParser form = cgi.FieldStorage() message = form.getvalue("message") customId = form.getvalue("customid") id = form.getvalue("id") filename = form.getvalue("filename") format = form.getvalue("format") targeterror = form.getvalue("targeterror") # Custom id can be used to store user ids or whatever is needed for the later processing of the # resulting screenshot grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")%>") result = grabzIt.GetResult(id) if result != None: # Ensure that the application has the correct rights for this directory. fo = open("results" + os.sep + filename, "wb") fo.write(result) fo.close() print "Status: 200 OK" print