0
有人向我沒有任何問題的長時間運行的網站刮刀。最近,我相信網站做了改變,現在我有會話持久性問題。下面是創建我的瀏覽器代碼:機械化/ CookieJar不保持會話持久性
def create_browser():
# Browser
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
return br
和這裏的登錄的代碼:
def login_stubhub(br):
br.open("https://myaccount.stubhub.com/login/Signin?")
br.select_form(name="signinForm_0")
br["loginEmail"] = 'username'
br["loginPassword"] = 'password'
br.method = "POST"
response = br.submit()
當我試圖打開一個頁面,要求我先登陸:
br.open(https://sell.stubhub.com/sellapi/event/4459340/section/null/seatmapdata)
我收到以下回復:
<data>
<errors>
<FormErrors>
<FormField>User Auth Check</FormField>
<ErrorMessage>
Either is not active or the session might have expired. Please login again.
</ErrorMessage>
</FormErrors>
</errors>
</data>
這是我在實現CookieJar前一天返回的錯誤。任何想法我可以嘗試修復會話持久性還有什麼?
謝謝!