我正在尝试从此html代码中删除“ href”链接:
我的代码是:
from selenium import webdriver
from splinter import Browser
from bs4 import BeautifulSoup
import requests as tt
ar=webdriver.Chrome('/Users/exepaul/Downloads/chromedriver/chromedriver')
url="https://www.python.org/about/"
browser=Browser("chrome")
browser.visit(url)
find_h=browser.find_by_css('div[class="medium-widget success-story-category last"]:nth-child(3) > ul:nth-child(1) > li:nth-child(1) > a')
for i in find_h:
print(i["href"])
但它什么也没返回
最佳答案
尝试以下方法,
div[class="medium-widget success-story-category last"]:nth-child(2)>ul:nth-child(n)>li:nth-child(1) > a
关于python - 为什么find_by_css中的nth-child不返回任何内容?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46483562/