- 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())
推薦閱讀
- Practical Network Scanning
- 黑客攻防技巧
- 安全技術運營:方法與實踐
- 工業控制網絡安全技術
- 軟件開發安全之道:概念、設計與實施
- Spring Security(Third Edition)
- 網絡安全設計、配置與管理大全
- Mastering Python for Networking and Security
- 物聯網信息安全技術
- ATT&CK視角下的紅藍對抗實戰指南
- 深入探索區塊鏈
- Linux安全實戰
- Hands-On Application Penetration Testing with Burp Suite
- 精通Veeam Backup&Replication(原書第2版)
- Mastering Windows Security and Hardening