mimiming avatar

python crawling 삽질3

mimiming

Published: 17 Jun 2018 › Updated: 17 Jun 2018python crawling 삽질3

python crawling 삽질3


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')

list = []
try:
while len(list) < 24492:
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
list.append(test)
print(list)
driver.find_element_by_xpath('//
[@id="searchVO"]/div[2]/div[2]/ol/li[12]/a').click()
if len(list) == 24492:
print(list)
except:
driver.quit()
pass

'다음'버튼을 누르면 자동으로 페이지가 넘어가게끔 해놔서 에러 남. 페이지 버튼별로 코드를 짜야됨.

Leave python crawling 삽질3 to:

Written by

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