facebook - How do I enable cookies with python requests -


i trying sign facebook python requests. when run following code: import requests

def get_facebook_cookie():     sign_in_url = "https://www.facebook.com/login.php?login_attempt=1"     #need post: email , pass     payload = {"email":"xxxx@xxxx.com", "pass":"xxxxx"}     headers = {"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "user-agent":"mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.132 safari/537.36"}     s   = requests.session()     r1  = s.get(sign_in_url, headers = headers, timeout = 2)     r   = s.post(sign_in_url,  data = payload, headers = headers, timeout = 2, cookies = r1.cookies)     print r.url     text = r.text.encode("ascii", "ignore")     fbhtml = open("fb.html", "w")     fbhtml.write(text)     fbhtml.close()     return r.headers   print get_facebook_cookie() 

( note url supposed redirect facebook.com-- still not that)

facebook returns following error: facebook error

(the email populated in email box -- know passing in atleast)

according requests session documentation handles of cookies, not think need passing in. however, have seen other elsewhere in order populate second request empty cookie gave shot.

the question is, why facebook telling me not have cookies enabled? there request header need pass in? urllib2 better choice this?

it looks according answer login facebook using python requests

there more data needs sent in, in order sign facebook.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -