我是python的新手,我正在提取一些数据。我想使用正则表达式提取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号?
答案 0 :(得分:0)
您可以像这样获得比赛:
address.group()
# 'Organization","name":"Gold
我希望这对您有帮助