Mar-25-2018, 05:00 PM
Hi
I'm writing to see if you guys can help me take my code to the next level.
As it is now it takes a list of urls from a CSV file list, it processes them and spits out the content into a CSV.
This is the code:
The idea naming convention will be something like the first 20 characters of the url or if it is less then all from (link).
I'm not asking you to write it for me but if you can give me some pointers on how to approach it and any links to similar code that would be great!
Thanks

I'm writing to see if you guys can help me take my code to the next level.
As it is now it takes a list of urls from a CSV file list, it processes them and spits out the content into a CSV.
This is the code:
import requests from bs4 import BeautifulSoup import csv filename = "siteslist.csv" f = open(filename, "r") url_list = f.read().split() f.close() for link in url_list: r = requests.get(link) r.encoding = 'utf-8' html_content = r.text #print(html_content) # this helped prove that the full content from all in list is listed f = csv.writer(open('output.csv', 'w')) f.writerow([html_content]) # these two lines add it to the CSV instead of terminalI'd like to add in a loop so that it will create not just one CSV but one for each of the urls in the source list CSV.
The idea naming convention will be something like the first 20 characters of the url or if it is less then all from (link).
I'm not asking you to write it for me but if you can give me some pointers on how to approach it and any links to similar code that would be great!
Thanks