-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebscrapping Gamefaqs part2.py
31 lines (29 loc) · 1.41 KB
/
webscrapping Gamefaqs part2.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
from bs4 import BeautifulSoup
html_doc = "C:\\Users\RONALDOAPARECIDODASI\Documents\MeusProjetos\Treinamento-Python\Beatiful_Soup\webscrapping Gamefaqs part2.html"
soup = BeautifulSoup(open(html_doc), 'html.parser')
a = soup.find_all('div')
'''[<div style="background-color:black;color:white;padding:20px;">
<h2>New York</h2>
<p> New York is the home of various cultures and ethnicities.</p>
</div>, <div style="background-color:black;color:white;padding:20px;">
<h2>London</h2>
<p> London is the home of various cultures and ethnicities.</p>
</div>]'''
#find parents
b = soup.find('div')
c = soup.find(string = 'New York').find_parent()
d = soup.find(string = 'New York').find_parents()
#find_siblings
e = soup.find(string = 'New York').find_next_siblings()
f = soup.find(string = 'New York').find_previous_siblings()
g = soup.find(string = 'New York').find_parent().find_next_siblings()
h = soup.find(string = 'New York').find_parent().find_previous_siblings()
i = soup.find(string = 'New York').find_parent().find_next_sibling().find_previous_siblings()
#find next and previous
j = soup.find(string = 'New York').find_next()
k = soup.find(string = 'New York').find_next().find_next()
l = soup.find(string = 'New York').find_all_next()
m = soup.find(string = 'London').find_all_next()
n = soup.find(string = 'New York').find_previous() #same as parent
o = soup.find(string = 'New York').find_all_previous() #same as all parents
print(a)