1
最近、Python Mechanizeで作業しています。& BeautifulSoupとリンクをたどる方法を学びました。 私は今、HTML入力から値を取得したいと思いますが、私はそれに非常に近いですが、私のコードはです。恐ろしいです!私はprint
たいもの はPython: 'input'から 'value'を取得するだけです。(Machineize + BeautifulSoup)
だけ
9574363984643591128220162336881714997023153074560071601385105141859609
ですから:
<!-- language: lang-js -->
<input size="100" name="query" value="95743639846435911282201623368817149970231530745600716013851051418596093791193" type="text">
私のコードは次のとおりです。
<!-- language: lang-py -->
response3 = br.follow_link(nr=11) # follow the link
soup = BeautifulSoup(response3, "lxml") # read the page
for n in soup.findAll('input'): # find all <input >
print n['value'] # print the "value" of all <input >
私のコードは、現在のすべて<input>
を印刷しています全てのページ!
しかし、私はちょうどname
属性を経由して、それを探すname="query"