
python 크롤링 삽질2
목표: 전과 동일
결과:1페이지 당 50행, 50페이지* 출력
원인 : for문 안에 있는 click
import requests
from bs4 import BeautifulSoup
import time
from selenium import webdriver
#from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome('C:\\Users\\kyooj\\Desktop\\chrome\\chromedriver')
driver.get('http://www.nsdi.go.kr/lxportal/?menuno=2776')
city = driver.find_element_by_id('shSido')
for option in city.find_elements_by_tag_name('option'):
if option.text == ' 서울특별시':
option.click()
driver.find_element_by_xpath(' // [ @ id = "searchVO"] / div[1] / div / select / option[5]').click()
driver.find_element_by_xpath('//[@id="icon_btn_write"]').click()
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
a_list = []
for i in range(1, 51):
path = '//[@id="searchVO"]/div[2]/table/tbody/tr'
num = i
num= str(num)
xpath = path+'['+num+']'
table_list = driver.find_element_by_xpath(xpath).text
test = table_list
print(test)
continue
driver.find_element_by_xpath('//[@id="searchVO"]/div[2]/div[2]/ol/li[12]/a').click()
print(type(test))
Leave python 크롤링 삽질2 to:
Read more #python posts
Best Posts From mimiming
We have not curated any of mimiming's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From mimiming
- python crawling 삽질3
- python 크롤링 삽질2
- python 크롤링 삽질
- Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
- Install Tensorwflow with Pycharm
- All about notepad++ 64bit plugin manager
- R Basic, Lists of Packages & Functions for loading files
- R basic, 'for loop' Calculating Leap Year
- day 1 ) bithum api r