Over a million developers have joined DZone.

Python - Change User-agent

·
// Cambiare user-agent con urllib


import urllib

class AppURLopener(urllib.FancyURLopener):

	version = 'Nokia6630/1.0 (2.3.129) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1'

urllib._urlopener = AppURLopener()


// Cambiare user-agent con urllib2


import urllib2

headers = { 'user-agent':'Nokia6630/1.0 (2.3.129) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1',
		    'keep-alive':'300',
		    'content-type':'application/x-www-form-urlencoded'
		  }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}