我是新来的,我在查资料。我想用正则表达式提取whatsapp号。 这是我的代码:
from textwrap import shorten
from bs4 import BeautifulSoup
import json
import requests
import re
url = 'https://m.propertyfinder.ae/en/rent/apartment-for-rent-dubai-dubai-marina-marina-promenade-delphine-tower-7276805.html'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')
whatsapp = re.match('{"type":"whatsapp","value":"([^"]+)"[^}]+}', soup)
print(whatsapp)
我得到的错误是:
Traceback (most recent call last):
File "/Users/evilslab/Documents/Websites/www.futurepoint.dev.cc/dobuyme/python/fetchFinder.py", line 11, in <module>
whatsapp = re.match('{"type":"whatsapp","value":"([^"]+)"[^}]+}', soup)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/re.py", line 189, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object
如何从源数据中提取whatsapp号码? 问题来源StackOverflow 地址:/questions/59386897/unable-to-pull-whatsapp-number-using-beautifulsoup-in-python
你可以得到这样的比赛:
address.group()
# 'Organization","name":"Gold
我希望这能有所帮助
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。