-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathweb.py
More file actions
36 lines (26 loc) · 728 Bytes
/
web.py
File metadata and controls
36 lines (26 loc) · 728 Bytes
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
#!/usr/bin/python3
import requests
from bs4 import BeautifulSoup
#print(dir(requests))
# we are using get request to load website a browser
# loading url
web=requests.get('http://192.168.10.30/adhoc.html')
print(web) # http response code
# web have more things also
#print(dir(web))
#print(web.content)
# text
s_data=web.text # this will print orginal front end data
print(web.url)
# now calling be model
# webdata, html parser --html5lib , htmllib , xml , lxml
soup=BeautifulSoup(s_data,'lxml') # html5 and css3
# only title tag
data=soup.select('title')
data1=soup.select('p')
print(data)
# explore soup var
print(data[0].text)
print(data1)
for i in data1:
print(i.text)