파이썬 동적페이지 크롤링때문에 일주일간 속머리를 앓고있습니다...고수님들 제발 도와주세요 ㅠㅠ

조회수 1965회

파이썬을 통해 데이터 크롤링을 하던 중, 동적페이지 크롤링에 대해 여쭤보고 싶은게 있습니다. 기존의 다른 사이트들은 request와 beautiful soup, selenium을 통해 대부분 크롤링이 되었는데 http://www.searchain.io/btcmonitor 위 사이트는의 동적페이지는 url이 변하지 않아 크롤링하는데 어려움이 있습니다.. 제가 크롤링하고싶은 데이터는 http://www.searchain.io/btcmonitor에서 large Amount trans out (24h)탭 -> 100-500을 클릭한 상태의 데이터들을 받아오고 싶습니다.

해당 데이터들을 조회해보니 xhr로 전송되고 있었고 xhr의 주소를 보니 http://scvelk.searchain.io/open/address/btc_trans_record?type=eth_single_record_count&size=15&page=1&numeric_type=1 로 연결되어 있었습니다. request, get요청을 통해 보내보았지만 제가원하는 json response가 아닌 {"errno":400,"errmsg":"sign err","timestamp":1542042533,"data":[]} 와 같은 에러메시지가 뜨고 있습니다.. 이 페이지는 request로 연결을 할 수 없는건가요? 아니면 제가 parameters를 제대로 입력하지 않아 생긴 오류인지 여쭤보고싶습니다..

계속된 난관에 부딪혀, 셀레늄을 이용하여 파싱하려고 노력해보았습니다.

셀레늄을 이용해 radio를 클릭한 후 정보를 가져오려고 했지만 .click()을 사용했을 때 Element is not clickable at point (314,227) because another element obscures it 라는 오류메세지가 뜨고있습니다. 다른 클래스가 위에 있어서 클릭이 안되는것 같습니다..ㅠㅠ 어떻게 해야 할까요? 제발 조언좀 부탁드리겠습니다..

1. requests 사용하여 코드는 이렇게 구현했습니다.

import requests URL = 'http://scvelk.searchain.io/open/address/btc_trans_record?type=eth_single_record_count&size=15&page=1&numeric_type=1' res = requests.get(URL) print(res.text)

응답--------------------- {"errno":400,"errmsg":"sign err","timestamp":1542178220,"data":[]}

2. selenium을 사용하여 코드는 이렇게 구현했습니다.

from selenium import webdriver from selenium.webdriver.firefox.options import Options from selenium.webdriver.support.ui import WebDriverWait

options = Options() options.add_argument("--headless") driver = webdriver.Firefox(firefox_options=options)

driver.get('http://www.searchain.io/btcmonitor')

WebDriverWait(driver, 3) c2 = driver.find_element_by_xpath("//*[@id='btccardbody']/div[1]/div[2]/div[2]/div[1]/div/div/div[1]/div/label[4]") c2.click()

html = driver.page_source print(html)

driver.close() driver.quit()

응답--------------------- selenium.common.exceptions.ElementClickInterceptedException: Message: Element is not clickable at point (314,227) because another element obscures it

  • (•́ ✖ •̀)
    알 수 없는 사용자
  • 제가 원하는 response의 타입은 {"errno":200,"errmsg":"success","timestamp":1542178054,"data":{"lists":[{"txhash":"30141a8c45b2f1827db7fcd8eae4280c4cc6a18ef20c810e6bc54f36186a1b2f","form":"3HMumQqCgDYvLAnHwriQvjiXqz8HQL7L5E","tags":["Bitfinex"],"value":"1106.40837679","current_value":"7035702.91","current_time":1542175814,"vin_sz":6,"vout_sz":4,"vin_amount":"1110.29881531","vout_amount":"1110.29869386","detail":{"form_list":[{"addr":"34ezk2czhsvfEA7KCwBGWpZVM5s7NHMChU","decimal_value":"3...................(중략)과 같은 json?형태의 response입니다! 알 수 없는 사용자 2018.11.14 15:58

1 답변

    1. 해당 API를 직접 치는 건 Access-Control-Allow-Origin 제약도 걸려 있고 각종 커스텀 요청헤더(X-CID, X-SIGN 등 처음 보는 이상한 것들)도 필요한 것 같아서 어려울 것 같습니다.
    2. 보아하니 원하시는 객체 언저리에 input.ivu-radio-input이 있고 여기에 onFocus 이벤트를 때리면 뭔가 일어나는 것 같은데 한번 셀레늄으로 그걸 시도해 보세요.

    이미지

    • 답변 너무 감사합니다. 고수분께서도 어렵다고 하시니 셀레늄으로 다시 계속 시도해봐야겠네요. 길을 알려주셔서 감사합니다 알 수 없는 사용자 2018.11.14 17:16

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)