使用正则表达式重新并找到文本包含的内容 ? 然后得到父代。
import re
import requests
from bs4 import BeautifulSoup
page = requests.get("https://www.spykar.com/faq")
soup = BeautifulSoup(page.content, 'html.parser')
for item in soup.find_all(text=re.compile("\?$")):
print(item.parent)
輸出:
Q: Do I have to register to shop at www.spykar.com?
Q: Do I have to disclose my e-mail id and phone number for registration?
Q: How secure is shopping with www.spykar.com or Is my personal Information secure?
Q: Are there any charges for registration?
Q: How do I get a new password?
Q: Can I edit my personal information?
Q: What kind of payment option does www.spykar.com offer?
Q: How do I know of www.spykar.com latest news and promotions?
Q: I have received a few emails from www.spykar.com. What are Orders Received, Orders Processed and Payment Receipt?
Q: I'm missing an item from my order, what do I do?
Q: What do I do if I receive a faulty item in my order?
Q: I have an incorrect item in my order, what do I do?
Q: Can I change my order after I've placed it?
Q: How long would it take for me to receive the refund of the returned/cancelled product?
Q: Within how many days can I return the product?
Q: How can I raise a return request on Spykar website?
Q: How do I return multiple products from a single order?
Q: Does Spykar pick up the product I want to return from my location?
Q: Why was my return request declined?
Q: Why did the return pickup of my product fail?
Q: How do I request a pickup again if the first attempt failed?
Q: How long would it take for me to receive the refund of the returned/cancelled product?
Q: Can I cancel my order after I've placed it?
Q: How long would it take for me to receive the refund of the returned/cancelled product?
Q: How long would it take for me to receive the refund of the returned/cancelled product?
Q: How can I exchange products I bought from www.Spykar.com?
Q: When will I receive the products I have ordered?
Q: Are there any delivery charges?
Q: Does Spykar deliver products outside India?
Q: How can I get my order delivered faster?
Q: What is ActifClub?
Q: What happens in ActifClub?
Q: What does a customer need to do to become an ActifClub member?
Q: Is there any joining fee?
Q: When will I get the points credited?
Q: What is the value of the points?
Q: How do I get my Rewards Points?
Q: How can I redeem the points?
Q: Where can I check number of points I have?
Q: If I forget to collect points, what should I do?
获取文本值。
print(item.parent.text)