Web浏览器中URL的格式不起作用

时间:2019-10-31 19:27:02

标签: python

Chrome表示找不到该网址。

但是,当我运行程序时,URL打印为: 'https://www.gettyimages.com/detail/photo/london-tower-bridge-river-thames-city-skyscrapers-royalty-free-image/860119662?adppopup=true'

如果将变量“ url”替换为webbrowser.open中上面的实际URL,它将完美地找到该网页。

这是实际代码:

# Reading an excel file using Python
import xlrd

# Give the location of the file
loc = ('F:\\Documents\\Fun Stuff\\Other\\bridges.xlsx')

# To open Workbook
book = xlrd.open_workbook(loc)
sheet = book.sheet_by_index(0)

# input is requested and stored in a variable
row_text = input('Row Number =  ')
# convert user input into an integer
row_number = int(row_text)

# For row “row_number” and column 2
cell_value = sheet.cell(row_number, 1)
url = str(cell_value)
url = url[5:]

#Verify url is extracted from Excel sheet
print(url)

# open-webpage
import webbrowser

#Path to webbrower
chrome_path = ('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s')

# open-webpage
webbrowser.get(chrome_path).open(url, new=0)

0 个答案:

没有答案