Python 如何在使用“爬行”搜索网页时找到特定模式;“靓汤”;?

Python 如何在使用“爬行”搜索网页时找到特定模式;“靓汤”;?,python,beautifulsoup,web-crawler,Python,Beautifulsoup,Web Crawler,我试图从网站上获取推特的用户名,我运行了以下代码,但我的结果没有显示任何错误消息,这有什么问题 import requests from bs4 import BeautifulSoup url = "https://www.twitaholic.com/" headers = {'User-Agent': 'Mozilla/5.0'} page = requests.get(url) soup = BeautifulSoup(page.content, 'html.parser') soup

我试图从网站上获取推特的用户名,我运行了以下代码,但我的结果没有显示任何错误消息,这有什么问题

import requests
from bs4 import BeautifulSoup

url = "https://www.twitaholic.com/"
headers = {'User-Agent': 'Mozilla/5.0'}
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
soup.findall(id="@(.*)")

我认为你在使用正则表达式时犯了一个错误。您应该编译该模式,然后将其传递给
soup

import requests
import re
from bs4 import BeautifulSoup

url = "https://www.twitaholic.com/"
headers = {'User-Agent': 'chrome'}
page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup(text=re.compile("@(.*)")))