클립 보드에 포함 된 URL을 다운로드하려고하지만 동일한 페이지를 반복해서 다운로드하지 못하도록하는 방법을 찾을 수 없습니다. 이것은 내가 시도한 것이지만, 오류가 발생합니다 TypeError: 'int' object has no attribute '__getitem__'
이것은 무엇을 의미합니까? 오류가 13 행에 있다고 말하면 URL이 유효한지 확인합니다.클립 보드에서 Python 다운로드 URL
In [3]: ?os.system
Type: builtin_function_or_method
String Form:<built-in function system>
Docstring:
system(command) -> exit_status
Execute the command (a string) in a subshell.
os.system을이 명령이 아닌 표준 출력을 명령의 종료 상태를 반환
여기clipboard = os.system("pbpaste")
는 이유는 다음과 같습니다
import time
import os
import urllib
basename = "page"
extension = ".html"
count=0
old_url = ""
while(1):
time.sleep(1) #check clipboard every second
clipboard = os.system("pbpaste") # get contents of clipboard
if clipboard[:4] == "http" and clipboard != old_url: # check if valid URL and is diffrent
while os.path.exists(basename+str(count)+extension): # Create new name
count=count+1
old_url = clipboard
name=basename+str(count)+extension
data=urllib.urlopen(clipboard).read() #get page data
file(name, "wb").write(data) # write to file
어떤 오류가 발생합니까? –
@ChristianTernus line 13 –