【发布时间】:2021-01-18 16:03:04
【问题描述】:
请帮我升级以下内容:这实际上是打开网站并截图。
我需要将 o/p 文件保存在所需位置。如果可能的话,请帮我取名字。
示例:如果输入为:https://www.amazon.in/B078BNQ318/ 我希望将文件保存为 B078BNQ318。请帮忙
import webbrowser
import pyautogui, time
import xlrd
URL = []
chrome_path = 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'
# change the loc as per your excel location
loc = ("C:\\Users\\dilip\\Documents\\URL.xlsx")
wb = xlrd.open_workbook(loc)
# open the first sheet
sheet = wb.sheet_by_index(0)
for i in range(sheet.nrows):
URL.append(sheet.cell_value(i, 0))
for i in range(0, len(URL)):
webbrowser.get(chrome_path).open(URL[i])
time.sleep(5)
screenshot = pyautogui.screenshot()
filename = "file" + str(i) + ".png"
screenshot.save(filename)
【问题讨论】:
标签: python python-3.x web-scraping python-requests