私は次のようなhtmlファイルを持っています:
<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>
next_pageのhref""/ 2811457 / follow?page = 2&gsid = 3_5bce9b871484d3af90c89f37 "を抽出する方法は?
それはhtmlの一部です、私はそれを明らかにするつもりです。私が美しいスープを使うとき、
print soup.find('a',href=re.compile('follow?page'))
それはNoneを返します、なぜですか?私はbeautifulsoupを初めて使用し、ドキュメントを確認しましたが、それでも混乱しています。
今私は醜い方法を使用しています:
urls = soup.findAll('a',href=True))
for url in urls:
if follow?page in url:
print url
もっと明確でエレガントな方法が必要です。