2017-06-06 8 views
0

pythonを使用して次のWebページからすべてのURLを取得できるようにしたいhttps://yeezysupply.com/pages/all私は見つけた他の提案を使ってみましたが、ウェブサイト私はすべてのURLを見つけることに終わるだろう。Pythonを使用して特定のWebページからすべてのリンクを取得したい

import urllib 
import lxml.html 
connection = urllib.urlopen('https://yeezysupply.com/pages/all') 

dom = lxml.html.fromstring(connection.read()) 

for link in dom.xpath('//a/@href'): 
    print link 

答えて

0

ページソースにはリンクがありません。ページがブラウザにロードされた後にJavascriptを使用して挿入されます。

1

おそらく、このために特別に設計されたモジュールを使用すると便利です。

/pages/jewelry 
/pages/clothing 
/pages/footwear 
/pages/all 
/cart 
/products/womens-boucle-dress-bleach/?back=%2Fpages%2Fall 
/products/double-sleeve-sweatshirt-bleach/?back=%2Fpages%2Fall 
/products/boxy-fit-zip-up-hoodie-light-sand/?back=%2Fpages%2Fall 
/products/womens-boucle-skirt-cream/?back=%2Fpages%2Fall 
etc... 

これはあなたが探しているものです:相続人のページ

#!/usr/bin/python3 

import requests, bs4 

res = requests.get('https://yeezysupply.com/pages/all') 

soup = bs4.BeautifulSoup(res.text,'html.parser') 
links = soup.find_all('a') 

for link in links: 
    print(link.attrs['href']) 

に相対リンクを取得し、迅速かつ汚いスクリプトは、このような出力を生成しますか?要求と美しいスープは掻きするための素晴らしいツールです。

+0

はいこれはまさに私が探していたものです –

関連する問題