I am trying to take a link from a csv file, download it, and change the filename, again using data from the csv file. Running the code below results in this error:
~AppDataLocalProgramsPythonPython39libsite-packages
equestssessions.py in get_adapter(self, url)
740
741 # Nothing matches :-/
--> 742 raise InvalidSchema("No connection adapters were found for {!r}".format(url))
743
744 def close(self):
InvalidSchema: No connection adapters were found for "('Links', 0 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
1 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
2 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
3 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
4 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
...
2790 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
2791 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
2792 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
2793 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
2794 https://eccdcf94738f34d487f9-0cee2c305dfdc401c...
Name: Links, Length: 2795, dtype: object)"
I have tried removing the header, and passing header = None
through read_csv, but I then can't specify the column to read from. Anyone have any ideas on how to remedy this?
from urllib.parse import urlparse
firstNames = pandas.read_csv('e://DELETEAFTERUSE/PwC_links.csv', usecols=['FirstName'])
lastNames = pandas.read_csv('e://DELETEAFTERUSE/PwC_links.csv', usecols=['LastName'])
links = lastNames = pandas.read_csv('e://DELETEAFTERUSE/PwC_links.csv', usecols=['Links'])
def run():
for item in firstNames.iteritems():
firstname = item
for item in lastNames.iteritems():
lastname = item
for item in links.iteritems():
ftd = requests.get(item)
split = urlparse.urlsplit(item)
filename = "e:/DELETEAFTERUSE/" + firstname + lastname + split.path.split("/")[-1]
open(filename, 'wb').write(ftd.content)
run()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…