파이썬 동적페이지 크롤링때문에 일주일간 속머리를 앓고있습니다...고수님들 제발 도와주세요 ㅠㅠ
조회수 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
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
- 해당 API를 직접 치는 건
Access-Control-Allow-Origin
제약도 걸려 있고 각종 커스텀 요청헤더(X-CID
,X-SIGN
등 처음 보는 이상한 것들)도 필요한 것 같아서 어려울 것 같습니다. - 보아하니 원하시는 객체 언저리에
input.ivu-radio-input
이 있고 여기에onFocus
이벤트를 때리면 뭔가 일어나는 것 같은데 한번 셀레늄으로 그걸 시도해 보세요.
- 해당 API를 직접 치는 건
댓글 입력