开发者社区> 问答> 正文

无法使用python中的BeautifulSoup获取whatsapp号码

我是新来的,我在查资料。我想用正则表达式提取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

展开
收起
kun坤 2019-12-25 21:46:17 618 0
1 条回答
写回答
取消 提交回答
  • 你可以得到这样的比赛:

    address.group()                                                                                                                                                                                  
    # 'Organization","name":"Gold 
    

    我希望这能有所帮助

    2019-12-25 21:46:53
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载