mmyjh86

[러닝-스크래핑2기] 인터파크 아이유 스크래핑

Nov 3rd, 2019
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import dart_fss as dart
  2. from selenium import webdriver
  3. from bs4 import BeautifulSoup
  4.  
  5. # 셀레늄만을 사용한 스크래핑
  6. driver = webdriver.Chrome('chromedriver.exe')
  7. url = "http://ticket.interpark.com/search/ticket.asp?search=%uC544%uC774%uC720"
  8. driver.get(url)
  9. ui = driver.find_element_by_css_selector("#playend_list > tr:nth-child(1) > td.info_Play > div > dl > dt > h4 > a")
  10. print(ui.text)
  11.  
  12. # BeautifulSoup을 조합한 스크래핑
  13. html = driver.page_source
  14. soup = BeautifulSoup(html, 'html5lib')
  15. result = soup.select("#playend_list > tr:nth-child(1) > td.info_Play > div > dl > dt > h4 > a")
  16. for r in result:
  17.     print(r.text)
RAW Paste Data