PythonでJRA内部urlからBeautifulSoupでデータを得る
JRAホームページで右クリックで[リンクのアドレスをコピー]を選択しても ”https://www.jra.go.jp/JRADB/accessS.html#”しか得られない
ページのソースを見るとホントのアドレスは ('/JRADB/accessS.html', 'pw01srl10062022040820221001/F4')らしい
このアドレスでページデータを取得する方法をググって見た
kichinoheさんの 'https://doanythings0.blogspot.com/2020/02/jrawebpython2.html'でこんなのを見つけた
import requests
from bs4 import BeautifulSoup
def url2soup(address):
arg1 = address[0]
arg2 = address[1]
with requests.post('https://www.jra.go.jp'+arg1, data='cname='+arg2) as r1:
r1.encoding = 'Shift_jis'
bs_obj = BeautifulSoup(r1.text, 'lxml')
return bs_obj
url = ('/JRADB/accessS.html', 'pw01srl10062022040820221001/F4')
print(url2soup(url).find('title').text)