실제 클릭이 관련되어 중대한 역할을합니까? PDF를 다운로드하려는 경우 요청 라이브러리를 사용하는 것이 좋습니다. Scrapy 사용을 고려할 수도 있습니다.
사이트에서 검색 할 때 Fiddler를 사용하여 HTTP POST 요청을 캡처 한 다음 Python에서이를 복제 할 수 있습니다.
다음은 시작 지점으로 유용한 코드입니다.이 기능은 서버에 로그인하여 대상 파일을 다운로드합니다. 이 동적 웹 사이트에서 작동하지 않습니다 따라서 자바 스크립트를 실행하지 않습니다를 제외하고 -
def login():
login_url = 'http://www.example.com'
payload = 'usr=username&pwd=password'
connection = requests.Session()
post_login = connection.post(data=payload,
url=login_url,
headers=main_headers,
proxies=proxies,
allow_redirects=True)
def download():
directory = "C:\\example\\"
url = "http://example.com/download.pdf"
filename = directory + '\\' + url[url.rfind("/")+1:]
r = connection.get(url=url,
headers=main_headers,
proxies=proxies)
file_size = int(r.headers["Content-Length"])
block_size = 1024
mode = 'wb'
print "\tDownloading: %s [%sKB]" % (filename, int(file_size/1024))
if r.status_code == 200:
with open(filename, mode) as f:
for chunk in r.iter_content(block_size):
f.write(chunk)
당신이 CSS 선택기를 이해하는 경우 다른 사용자가 ID 또는 XPath는 또는 다른 것들에 의해 요소를 찾을 수 있습니다 .... https://www.google.com/search?q=python+to+log+into+website&client=ubuntu&channel=cs&aq=f&oq=python+to+log+into+website&aqs=chrome.0.57j62l3.3901&sourceid=chrome&ie=UTF -8 – dm03514
지금까지 시도한 것을 공유하십시오. – Ani