Last active
December 31, 2020 04:35
-
-
Save sangwon090/54d4f93a0c0bbf04a91cf0b75855631c to your computer and use it in GitHub Desktop.
[Python] FIFA Online 4 Crawler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from collections import namedtuple | |
url = "http://fifaonline4.nexon.com/datacenter/index" | |
driver = webdriver.Chrome("./chromedriver.exe") | |
player_data = namedtuple("player_data", "season name price") | |
players = [] | |
driver.get(url + "?strPlayerName=" + "<PLAYER NAME HERE>") | |
driver.implicitly_wait(2500) | |
player_elements = driver.find_elements_by_css_selector("#divPlayerList > div.tr") | |
for player_element in player_elements: | |
class_image = player_element.find_element_by_css_selector("div > div.td.default > div.player_info > div.info_top > div.season > img").get_attribute("src") | |
player_class = None | |
if class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/LIVE.png": | |
player_class = "LIVE" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/17.png": | |
player_class = "17" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/18TOTY.png": | |
player_class = "18TOTY" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/TKI.png": | |
player_class = "TKI" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/KFA.png": | |
player_class = "KFA" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/NHD.png": | |
player_class = "NHD" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/MCFC.png": | |
player_class = "MCFC" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/TB.png": | |
player_class = "TB" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/TT.png": | |
player_class = "TT" | |
elif class_image == "http://s.nx.com/s2/game/fo4/obt/externalAssets/season/PLC.png": | |
player_class = "PLC" | |
else: | |
player_class = "UNKNOWN" | |
player_name = player_element.find_element_by_css_selector("div > div.td.default > div.player_info > div.info_top > div.name").text | |
player_pay = player_element.find_element_by_css_selector("div > div.td.td_ar > span.pay").text | |
print("[ " + player_class + " ] " + player_name + " <" + player_pay + "> ") | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment