HTTP Error 406: Not Acceptable Python urllib2 -


i following error code below.

http error 406: not acceptable python urllib2

this first step before use beautifulsoup parse page.

import urllib2 opener = urllib2.build_opener() opener.addheaders = [('user-agent', 'mozilla/5.0')] url = "http://www.choicemoney.us/retail.php" response = opener.open(url) 

all appreciated.

the resource identified request capable of generating response entities have content characteristics not acceptable according accept headers sent in request. [rfc2616]

based on code , rfc describes assume need set both key , value of user-agent header correctly.

these correct examples:

  • mozilla/5.0 (x11; u; linux i686) gecko/20071127 firefox/2.0.0.11

  • mozilla/5.0 (windows nt 6.1) applewebkit/537.36 (khtml, gecko) chrome/41.0.2228.0 safari/537.36

  • mozilla/5.0 (macintosh; intel mac os x 10_9_3) applewebkit/537.75.14 (khtml, gecko) version/7.0.3 safari/7046a194a

just replace following.

opener.addheaders = [('user-agent', 'mozilla/5.0 (macintosh; intel mac os x 10_9_3) applewebkit/537.75.14 (khtml, gecko) version/7.0.3 safari/7046a194a')] 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -