This code opens the URL and adds /names
to the end and opens the page and prints a line in test1.csv
:
import urllib2 import re import csv url = ("http://www.example.com") bios = [u'/name1', u'/name2', u'/name3'] csvwriter = csv.writer(open("/test1.csv", "a")) for l in bios: OpenThisLink = url + l response = urllib2.urlopen(OpenThisLink) html = response.read() item = re.search('(JD)(.*?)(\d+)', html) if item: JD = item.group() csvwriter.writerow(JD) else: NoJD = "NoJD" csvwriter.writerow(NoJD)
But I get this result:
J,D,",", ,C,o,l,u,m,b,i,a, ,L,a,w, ,S,c,h,o,o,l,....
If I change the line to ("JD", "Columbia Law School" ....), then I get
JD, Columbia Law School...)
I could not find in the documentation how to specify a delimeter.
If I try to use delimenter
, I get this error:
TypeError: 'delimeter' is an invalid keyword argument for this function
Thanks for the help.