-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyipscan.py
42 lines (36 loc) · 1.39 KB
/
pyipscan.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import requests
from bs4 import BeautifulSoup as BS
from raven import Client
DOCKER_NAME = os.environ.get("DOCKER_NAME","")
SENTRY_DNS = os.environ.get("SENTRY_DNS", "http://9b27dfdbe05447f295676178f192ba55:[email protected]:9000/6")
session = requests.session()
headers = {
"referer": "https://www.google.com.tw/",
"user-agent": "mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 "
"(khtml, like gecko) "
"chrome/46.0.2490.86 safari/537.36"}
session.headers.update(headers)
res = session.get('https://whatismyipaddress.com/')
soup = BS(res.text, "html5lib")
ip = [a.text for a in soup.select('#section_left a')][0]
client = Client(dsn = SENTRY_DNS, name = DOCKER_NAME)
client.captureMessage(ip)
def _get_session():
session = requests.session()
headers = {
"referer": "https://www.amazon.com/",
"user-agent": "mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 "
"(khtml, like gecko) "
"chrome/46.0.2490.86 safari/537.36"}
session.headers.update(headers)
return session
def _get_product_url(product_id):
return 'https://www.amazon.com/dp/' + product_id
pid = "B00XQ4Z1Q0"
url = _get_product_url(pid)
res = session.get(url)
soup = BS(res.text, "lxml")
print(soup.select("#dp-container")[0].text)
print("===================================")
print(soup.text)