Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripting.py
More file actions
Latest commit
35 lines (27 loc) · 1.08 KB
/
Copy pathscripting.py
File metadata and controls
35 lines (27 loc) · 1.08 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
importrequests
frombs4importBeautifulSoup
importsqlite3, sql
URL="https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number"
r=requests.get(URL)
soup=BeautifulSoup(r.content, 'html5lib')
pokemon_list= []
table=soup.find('table', attrs= {'align':'center'})
pokemon_info=table.findAll('tr', attrs= {'style': 'background:#FFF'})
forrowinpokemon_info:
pokemon= {'RegionalDex': "", 'NationalDex': "",
'Name': "", 'Primary Type': "", 'Secondary Type': ""}
count=1
forindiv_infoinrow.findAll('td'):
ifcount==1:
pokemon['RegionalDex'] =indiv_info.text
ifcount==2:
pokemon['NationalDex'] =indiv_info.text
ifcount==4:
pokemon['Name'] =indiv_info.text
ifcount==5:
pokemon['Primary Type'] =indiv_info.text
ifcount==6:
pokemon['Secondary Type'] =indiv_info.text
count=count+1
pokemon_list.append(pokemon)
sql.insert_pokemon(pokemon_list)