2

i'm trying to access the Amazon Seller Central through python and Mechanize.

This is my code, i think it's working, but when i check a page that is only accessible of you login, it get redirected to a page that says: "to continue using Amazon, please activate cookies in you browser, once the cookies enabled, please click on the button below to go back to the previous page"

How can i enable cookies in my python or mechanize setup?

import mechanize
import urllib2
import cookielib
import requests

browser = mechanize.Browser()
browser.set_handle_robots(False)   # ignore robots
browser.set_handle_refresh(False)  # can sometimes hang without this
cj = cookielib.CookieJar()
browser.set_cookiejar(cj)

USERNAME = 'MyUsername'
PASSWORD = 'MyPass'
response = browser.open("https://sellercentral.amazon.fr/gp/homepage.html")
browser.select_form("signinWidget")
browser.form['username'] = USERNAME
browser.form['password'] = PASSWORD
responsecheck = browser.submit()
print responsecheck.read()


check = browser.open("https://sellercentral.amazon.fr/gp/global-selling/gateway-widget-crosslisting-potential/crosslisting-potential-widget-internals.html?_=1411311676093")
print check.read()     

Thank you in advance,

Thomas

user3650471
  • 53
  • 1
  • 7
  • possible duplicate of [Scrape a web page that requires they give you a session cookie first](http://stackoverflow.com/questions/9754807/scrape-a-web-page-that-requires-they-give-you-a-session-cookie-first) – user1767754 Sep 21 '14 at 19:54
  • I generally just use requests.Session but it stores auth cookies well. Might want to look into that and just use BeautifulSoup for the scraping bit depending on how much more of the mechanize functionality you really need. – BWStearns Sep 21 '14 at 19:58

1 Answers1

-1

Might be a bit late, but have you tried setting the user agent? I had the the same message when using PhantomJS. Changing the user agent to "Mozilla/6.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.1.1547.57 Safari/537.36" solved it for me.

chedda
  • 73
  • 1
  • 8