On Mar 23, Stefan Schneider <[EMAIL PROTECTED]> wrote:

> I wonder if there is a way to set the Useragent from my own script
> instead using the default "self.addheaders = [('User-agent',
> 'Mozilla/5.0')]" one from "IMDbPY-2.9/imdb/parser/http/__init__.py" ?

Hi!
Actually a direct method is not provided, but you can always do this:

  from imdb import IMDb
  ia = IMDb() # or IMDb('mobile')
  
  new_headers = []
  for header, value in ia.urlOpener.addheaders:
      if header.lower() == 'user-agent':
          continue
      new_headers.append((header, value))

  # Here, if you want, you can add your own header:
  new_headers.append(('User-agent', 'MyMightyBrowser 6.0'))

  ia.urlOpener.addheaders = new_headers

> Many thanks, keep up the good work,

HTH.
PS: out of curiosity, why do you need to change the User-agent header?

-- 
Davide Alberani <[EMAIL PROTECTED]> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel

Reply via email to