- Python Penetration Testing Cookbook
- Rejah Rehim
- 88字
- 2021-07-02 23:08:41
How to do it...
We use custom user agent string in the request as following:
- First, import the required modules:
>>> import urllib.request
- Then define the user agent we plan to specify for the request:
>>> user_agent = ' Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0'
- Set up the headers for the request:
>>> headers = {'User-Agent': user_agent}
- Create the request as follows:
>>> request = urllib.request.Request("https://www.packtpub.com/", headers=headers)
- Request the web page with urlopen:
>>> with urllib.request.urlopen(request) as response: ... with open('with_new_user_agent.html', 'wb') as out: ... out.write(response.read())
推薦閱讀
- Extending Symfony2 Web Application Framework
- 黑客大曝光:無線網絡安全(原書第3版)
- Kali Linux Social Engineering
- Mastering Kali Linux for Advanced Penetration Testing
- INSTANT Windows PowerShell
- Python Penetration Testing Cookbook
- 數據安全與隱私計算(第3版)
- 信息安全等級保護測評與整改指導手冊
- 信息安全工程與實踐
- Cybersecurity Threats,Malware Trends,and Strategies
- 企業數據安全防護指南
- Securing Network Infrastructure
- 信息組織
- 黑客攻防入門
- 2023—2024年中國網絡安全發展藍皮書