[Tutor] Import CSV

Alan Gauld alan.gauld at yahoo.co.uk
Thu Dec 13 19:41:45 EST 2018


On 13/12/2018 16:56, Sammy Lee wrote:
> I need help on how to open a webpage and save the HTML to a given file path, given a URL.

You can use the standard library urllib module to fetch the
file but most folks find the requests module easier to use.
requests is a 3rd party module you will need to install.

You can read about how to use urllib in the Web Clients
topic of my tutorial(see below).

Saving the HTML is just the same as saving any other string
to a file. Do you know how to do that?
If not the file handling topic of my tutor covers it.

Your subject mentions CSV but your text only says HTML.
If you do have a CSV file then the Python csv module
will deal with parsing the CSV data for you. The module
documentation is quite helpful.

If you need to pare HTML to extract the data then the
standard http module can help there. See the Web Clients
topic in my tutorial for more on that too.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list