]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fake headers to pretend this is a real browser.
authorOleg Broytman <phd@phdru.name>
Thu, 27 Dec 2007 20:23:59 +0000 (20:23 +0000)
committerOleg Broytman <phd@phdru.name>
Thu, 27 Dec 2007 20:23:59 +0000 (20:23 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@138 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Robots/bkmk_rsimple.py

index ae7c39e481be8e30b144981bf18a1a8aa32b19d2..c78a38be947572251a38482928b4cedd3caa066f 100644 (file)
@@ -45,8 +45,18 @@ class MyURLopener(urllib.URLopener):
 
 urllib._urlopener = MyURLopener()
 
-server_version = "bookmarks_db (Python-urllib/%s)" % urllib.__version__
-urllib._urlopener.addheaders[0] = ('User-agent', server_version)
+# Fake headers to pretend this is a real browser
+_version = "Links (2.1; Linux 2.6 i686; 80x25)"
+urllib._urlopener.addheaders[0] = ('User-Agent', _version)
+_version = "bookmarks_db (Python-urllib/%s)" % urllib.__version__
+urllib._urlopener.addheader('X-User-Agent', _version)
+
+urllib._urlopener.addheader('Connection', 'close')
+urllib._urlopener.addheader('Content-Length', '0')
+urllib._urlopener.addheader('Accept', '*/*')
+urllib._urlopener.addheader('Accept-Language', 'ru,en')
+urllib._urlopener.addheader('Cache-Control', 'max-age=300')
+urllib._urlopener.addheader('Referer', 'http://www.yahoo.com/')
 
 
 def get_error(msg):