rajatomar788 / pywebcopy

Locally saves webpages to your hard disk with images, css, js & links as is.
https://rajatomar788.github.io/pywebcopy/
Other
527 stars 106 forks source link

how to change user agent? #29

Closed marshonhuckleberry closed 4 years ago

marshonhuckleberry commented 4 years ago

how to change user agent?

rajatomar788 commented 4 years ago

The pywebcopy uses a inbuilt requests library session which stores the headers and cookies and all other data during all the requests. You can customize this session before start to modify the user-agent or cookies or headers etc.

import pywebcopy 

pywebcopy.SESSION.headers['User-Agent'] = "your-custom-useragent"

pywebcopy.config.setup_config('http://google.com',  '/path/to/downloads/', debug=True)
pywebcopy.save_webpage('http://google.com')

You can learn more about manipulation of requests session from documentation.

https://2.python-requests.org/en/master/user/advanced/