Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

selenium webdriver - Filter for the Numbers Following a String on a Webpage With a Python Web Scraper

I'm trying to filter for the total number of followers between all stories on an account. I've managed to do all the basics and put everything needed in the 'header' variable, I just need to filter out everything except the number following "Follows:" but can't find how to do that. Any help is appreciated.

(Yes, I know I have a lot of imports I don't need, this project was kind of slapped together and I copied the imports from another Webscraping project I'm working on)

Edit: The end goal is to add all of the follows together

import bs4
import sys
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import pandas as pd
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

driver = webdriver.Chrome(executable_path='C:/Users/Curious Beats/Downloads/chromedriver.exe')

driver.get("https://www.fictionpress.com/u/541077/Imperfect-Princess")


page_html = driver.page_source
page_soup = soup(page_html, "html.parser")

list_header = []
header = page_soup.find_all("div",{"class":"z-padtop2 xgray"})
for items in header:
        try:
            list_header.append(items.get_text())
        except:
            continue

driver.quit()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...