尝试抓取数据,但无法全部抓取 (Python)
Trying to scrape data, but can't scrape it all (Python)
我正在尝试从该页面中获取关注者数量 http://freelegalconsultancy.blogspot.co.uk/
,但似乎无法获取。我试过使用 urllib
、urllib2
、urllib3
、selenium
和 beautiful soup
,但没有成功吸引追随者。这是我的代码目前的样子:
import urllib2
url = "http://freelegalconsultancy.blogspot.co.uk/"
opener = urllib2.urlopen(url)
for item in opener:
print item
我将如何拉动粉丝数量?
尝试使用 selenium
代码如下:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://freelegalconsultancy.blogspot.co.uk/')
driver.switch_to_frame(driver.find_element_by_xpath('//div[@id="followers-iframe-container"]/iframe'))
followers_text = driver.find_element_by_xpath('//div[@class="member-title"]').text
followers = int(followers_text.split('(')[1].split(')')[0])
最后一行有点粗鲁,喜欢可以改
我正在尝试从该页面中获取关注者数量 http://freelegalconsultancy.blogspot.co.uk/
,但似乎无法获取。我试过使用 urllib
、urllib2
、urllib3
、selenium
和 beautiful soup
,但没有成功吸引追随者。这是我的代码目前的样子:
import urllib2
url = "http://freelegalconsultancy.blogspot.co.uk/"
opener = urllib2.urlopen(url)
for item in opener:
print item
我将如何拉动粉丝数量?
尝试使用 selenium
代码如下:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://freelegalconsultancy.blogspot.co.uk/')
driver.switch_to_frame(driver.find_element_by_xpath('//div[@id="followers-iframe-container"]/iframe'))
followers_text = driver.find_element_by_xpath('//div[@class="member-title"]').text
followers = int(followers_text.split('(')[1].split(')')[0])
最后一行有点粗鲁,喜欢可以改