別のSOの質問で説明されているように、MacOSでページ( Kaggle Competitions )を解析しようとしていました:xpath
curl "https://www.kaggle.com/competitions/search?SearchVisibility=AllCompetitions&ShowActive=true&ShowCompleted=true&ShowProspect=true&ShowOpenToAll=true&ShowPrivate=true&ShowLimited=true&DeadlineColumnSort=Descending" -o competitions.html
cat competitions.html | xpath '//*[@id="competitions-table"]/tbody/tr[205]/td[1]/div/a/@href'
href
それは、テーブル内のリンクを取得するだけです。
ただし、値を返す代わりに、xpath
検証.html
を開始し、のようなエラーを返しますundefined entity at line 89, column 13, byte 2964
。
man xpath
存在せず、何もないのでxpath --help
、私は立ち往生しています。また、多くの同様のソリューションxpath
は、MacOS ではなく、GNU ディストリビューションに関連しています。
bashでXPath経由でHTML要素を取得する正しい方法はありますか?