我知道这里销售的Adhury(http://oktaykilic.com/my-projects/google-alerts-api-python/),但我很想知道,为什么我现在做这项工作的我是徒劳的。
这就是我迄今为止所做的事情:
class GAlerts():
def __init__(self, uName = USERNAME , passWord = PASSWORD ):
self.uName = uName
self.passWord = passWord
def addAlert(self):
self.cj = mechanize.CookieJar()
loginURL = https://www.google.com/accounts/ServiceLogin?hl=en&service=alerts&continue=http://www.google.com/alerts
alertsURL = http://www.google.com/alerts
#log into google
initialRequest = mechanize.Request(loginURL)
response = mechanize.urlopen(initialRequest)
#put in form info
forms = ClientForm.ParseResponse(response, backwards_compat=False)
forms[0][ Email ] = self.uName
forms[0][ Passwd ] = self.passWord
#click form and get cookies
request2 = forms[0].click()
response2 = mechanize.urlopen(request2)
self.cj.extract_cookies(response, initialRequest)
#now go to alerts page with cookies
request3 = mechanize.Request(alertsURL)
self.cj.add_cookie_header(request3)
response3 = mechanize.urlopen(request3)
#parse forms on this page
formsAdd = ClientForm.ParseResponse(response3, backwards_compat=False)
formsAdd[0][ q ] = Hines Ward
#click it and submit
request4 = formsAdd[0].click()
self.cj.add_cookie_header(request4)
response4 = mechanize.urlopen(request4)
print response4.read()
myAlerter = GAlerts()
myAlerter.addAlert()
就我所知,它成功地在主页上登录并接上了警示,但在我进入问询和“立点”时,它把我送到一个页上,说“请进入有效的电子邮件地址”。 缺乏某种认证的Im? 我也不理解如何改变从神论中 custom倒的观念? 任何想法?
增 编