>  Q&A  >  본문

html - Python爬虫,翻页数据怎么爬,URL不变

网址:http://quote.eastmoney.com/ce...
我想爬所有页的名称数据,(这里只有两页),判断有没有下一页的条件该怎么写呢?
代码:

from selenium import webdriver
driver=webdriver.PhantomJS()

url='http://quote.eastmoney.com/center/list.html#28003684_0_2'
driver.get(url)
usoup = BeautifulSoup(driver.page_source, 'xml')
n=[]
while True:
     t=usoup.find('table',{'id':'fixed'})
     utable=t.find_all('a',{'target':'_blank'})
     for i in range(len(utable)):
          if i % 6 ==1:
             n.append(utable[i].text)
          if #停止条件怎么写:
            break
     driver.find_element_by_xpath(r'//*@id="pagenav"]/a[2]').click()
     usoup = BeautifulSoup(driver.page_source, 'xml')

后面这里就不会写了。。。

大家讲道理大家讲道理2741일 전803

모든 응답(4)나는 대답할 것이다

  • 巴扎黑

    巴扎黑2017-04-18 10:33:18

    각 페이지의 항목을 판단할 수 있으며, 각 페이지에는 20개의 항목이 있습니다. 현재 페이지의 항목이 20개 미만인 경우 이 페이지가 마지막 페이지라는 의미이므로 현재 페이지를 크롤링한 후 중지해야 합니다.

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-18 10:33:18

    그런데 이 양식에는 jsonp 반환 인터페이스가 없나요? 왜 아직도 오르나요?

    회신하다
    0
  • PHPz

    PHPz2017-04-18 10:33:18

    jsonp 인터페이스를 사용하므로 그냥 사용하세요.

    크롤링해야 한다면 Selenium + phantomjs와 같은 시뮬레이션 페이지를 통해서만 얻을 수 있습니다.

    회신하다
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:33:18

    http://nufm.dfcfw.com/EM_Fina...{순위:[(x)],페이지:(pc)}&token=7bc05d0d4c3c22ef9fca8c2a912d779c&jsName=quote_123&_g=0.5385195357178545

    회신하다
    0
  • 취소회신하다