我正在尝试使用 BeautifulSoup 在网站中进行一些网络爬网。但是当我尝试获取 div 类 AddressInfo 中的内容时出现错误,这是我要抓取的网站的一部分:
<h4>Altônia</h4>
<div class="addressInfo">
Rua Getulio Vargas, 1201<br>
Centro - Iporã - PR<br>
87550-000<br>
<br>
(44) 3659-2721<br>
<a href="mailto:altoniacentro.pr@escolas.com.br">altoniacentro.pr@escolas.com.br</a><br>
</div>
这是我的代码:
from urllib import urlopen
from BeautifulSoup import BeautifulSoup
import re
# Copy all of the content from the provided web page
webpage = urlopen('site url....').read()
# Grab everything that lies between the h4 tags using a REGEX
patFinderTitle = re.compile('<h4>(.*)</h4>')
# Grab everything that lies between the class addressInfo tags using a REGEX
patFinderAddress = re.compile('<div class="addressInfo">(.*)</div>') **<- get error here**
这是我得到的错误:
raise ValueError('Cannot process flags argument with a compiled pattern') ValueError: Cannot process flags argument with a compiled
图案
我该如何解决这个问题?