-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlol_ob_scrap.py
54 lines (42 loc) · 1.48 KB
/
lol_ob_scrap.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
43
44
45
46
47
48
49
50
51
52
53
54
import time
from inspect import getfile
import os
import re
from urllib import request
from urllib.error import HTTPError
from bs4 import BeautifulSoup
import requests
from selenium import webdriver
site_url = 'https://fow.kr'
url = "https://fow.kr/find/"
def main():
get_player_list()
def aaaa(name):
res = requests.get(url + name)
res.raise_for_status()
soup = BeautifulSoup(res.text, "lxml")
tag_A_s = soup.find_all('a', attrs={"class": "sbtn green small"}) # 전체 영역에서 'a' 태그를 찾지 않고 인기 급상승 영역으로 범위 제한
for i in tag_A_s:
href = i.attrs['href']
temp = href.split('&')[2]
ID = temp.split('=')[1]
os.chdir('C:/Users/gpark/PycharmProjects/flaskProject/project/save2')
request.urlretrieve(site_url + href, 'fow_' + ID + '.bat')
print(f"{ID} Done")
time.sleep(2)
print(f"{name} Done")
time.sleep(4)
def get_player_list():
driver = webdriver.Chrome('./chromedriver')
driver.implicitly_wait(1)
driver.get('https://fow.kr/ranking#51')
driver.implicitly_wait(1)
table = driver.find_element_by_class_name('tablesorter.rank_ranking')
tbody = table.find_element_by_tag_name("tbody")
rows = tbody.find_elements_by_tag_name("tr")
for index, value in enumerate(rows):
body = value.find_elements_by_tag_name("td")[1]
a = body.find_element_by_tag_name("a").get_attribute('href')
name = a.split('/')[4]
aaaa(name)
main()