-1
私はクラス= "pntc-txt"のdivからすべてのリンクを取得するスクリプトをコーディングしています。<a>
タグから取得したいhref属性と、<a href="">Something</a>
の間のテキスト。後にそのURLとテキストを取ってデータベースに挿入します。<a>からURLとタイトルを取得する方法beautifulSoupでタグ
import urllib.request
from bs4 import *
sock = urllib.request.urlopen("http://as.com/tag/moto_gp/a/")
htmlSource = sock.read()
sock.close()
soup = BeautifulSoup(htmlSource)
for div in soup.findAll('div', {'class': 'pntc-txt'}):
a = div.findAll('a')
print (a)
完全にここに文書化されていますhttps://www.crummy.com/software/BeautifulSoup/bs4/doc/#attributes –