python文本查找指定字符_在 python 的标签文本文件中查找带有特定字符串的标签,如"?"。...

使用正则表达式重新并找到文本包含的内容 ? 然后得到父代。

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值