2017-02-09 2 views
0

後で一部のデータを解析するために、Python(2.7)とライブラリ "request"を使用して、次のHTML(ビデオ付きHTMLフレームの一部です)からリンクをクリックする必要があります。私はいくつかの進歩を遂げましたが、まだ次のビデオを表示することはできませんでした。助言がありますか?次のリンクをクリックするためのPythonリクエスト

<div class="nextvideo"> 
    <a href="#" data-link="https://player.vimeo.com/video/133977055?title=0&;byline=0&;portrait=0"></a> 

import requests 
from lxml import html 

session_requests = requests.session() 
url = "https://www.exmple.com/" 
result = session_requests.get(url) 

payload = { 
     "title": "0" 
     "byline": "0", 
     "portrait": "0", 
} 

result = session_requests.post(
    "https://player.example.com/video/133956055", 
    params = payload, 
) 

答えて

1

私は最終的に、ライブラリのセレンを使用して私の問題への解決策を見つけました。

私は解決策を引用以下:

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.support.ui import Select 
from lxml import html 
import time 


def clck(xpth): 
    driver.find_element_by_xpath(xpth).click() 



driver = webdriver.Chrome() 
driver.get("http://www.example.com") 

#username 
element = driver.find_element_by_xpath('your xpath') 
element.send_keys("yourusername") 

#password 
element2 = driver.find_element_by_xpath('your xpath') 
element2.send_keys("yourpass") 
time.sleep(1) 

#submit 
clck('your xpath') 

#Menu or next video 
clck('your xpath') 
ライブラリについて

の詳細は以下のリンクで見ることができます:

http://selenium-python.readthedocs.io/

http://lxml.de/

Is there a way to get the xpath in google chrome?

関連する問題