Tôi có một file html như sau: "/ 2.811.457/làm theo page = 2 & gsid = 3_5bce9b871484d3af90c89f37"BeautifulSoup không thể tìm thấy href trong tập tin sử dụng biểu thức chính quy
<form action="/2811457/follow?gsid=3_5bce9b871484d3af90c89f37" method="post">
<div>
<a href="/2811457/follow?page=2&gsid=3_5bce9b871484d3af90c89f37">next_page</a>
<input name="mp" type="hidden" value="3" />
<input type="text" name="page" size="2" style='-wap-input-format: "*N"' />
<input type="submit" value="jump" /> 1/3
</div>
</form>
làm thế nào để trích xuất các href" ở next_page?
nó là một phần của html, tôi dự định để làm cho nó rõ ràng. Khi tôi sử dụng BeautifulSoup,
print soup.find('a',href=re.compile('follow?page'))
nó trở lại Không, tại sao? Tôi mới đến beautifulsoup, và tôi đã xem tài liệu, nhưng vẫn còn bối rối.
bây giờ tôi sử dụng một cách xấu xí:
urls = soup.findAll('a',href=True))
for url in urls:
if follow?page in url:
print url
Tôi cần một cách rõ ràng hơn và thanh lịch.
đánh dấu, bạn sẽ cho tôi biết cách trích xuất "1/3" từ tệp html? – young001