-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexple_bs4_1.py
More file actions
43 lines (31 loc) · 1.06 KB
/
exple_bs4_1.py
File metadata and controls
43 lines (31 loc) · 1.06 KB
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
43
from bs4 import BeautifulSoup
import requests
helloworld = "<p>Hello World</p>"
soup_string = BeautifulSoup(helloworld, "html.parser")
print(soup_string)
url = "https://www.barnesandnoble.com/b/barnes-noble-classics/_/N-rqv"
response = requests.get(url)
soup_page = BeautifulSoup(response.content,"html.parser")
print(soup_page)
with open("foo.html") as foo_file:
soup = BeautifulSoup(foo_file, "html.parser")
print(soup)
html_atag = """<html><body><p>Test html a tag example</p>
<a href="http://www.test.com">Home</a>
</body>
</html>"""
soup = BeautifulSoup(html_atag,"html.parser")
atag = soup.a
print(atag)
url = r"https://en.wikipedia.org/wiki/List_of_stations_of_the_Paris_M%C3%A9tro"
response = requests.get(url)
soup_page= BeautifulSoup(response.content,"html.parser")
print(soup_page)
tag_th=soup_page.find_all('th')
print(tag_th)
with open("ecologicalpyramid.html") as ecological_pyramid:
soup = BeautifulSoup(ecological_pyramid,"html.parser")
produce_stories = soup.find_all("ul")
print(produce_stories.li.div.string)
search = soup.find_all(text="fo")
print(search)