FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
violentPythonForHackers/CH6/3-userAgentTest.py at master · techvoltage/violentPythonForHackers · GitHub
techvoltage
violentPythonForHackers
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
violentPythonForHackers
/
CH6
/
3-userAgentTest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
18 lines (13 loc) · 447 Bytes
Breadcrumbs
violentPythonForHackers
/
CH6
/
3-userAgentTest.py
Copy path
File metadata and controls
executable file
·
18 lines (13 loc) · 447 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/python
# -*- coding: utf-8 -*-
import
mechanize
def
testUserAgent
(
url
,
userAgent
):
browser
=
mechanize
.
Browser
()
browser
.
addheaders
=
userAgent
page
=
browser
.
open
(
url
)
source_code
=
page
.
read
()
print
source_code
url
=
'http://whatismyuseragent.dotdoh.com/'
userAgent
=
[(
'User-agent'
,
'Mozilla/5.0 (X11; U; '
+
\
'Linux 2.4.2-2 i586; en-US; m18) Gecko/20010131 Netscape6/6.01'
)]
testUserAgent
(
url
,
userAgent
)
Back
|
FazBrowse Home
|
New Git URL