store the data instead of printing it - in to a mysql-db

Einfach Dinge, die nichts mit XAMPP, Apache Friends, Apache, MySQL, PHP und alle dem zu tun haben. Allerlei halt. ;)

store the data instead of printing it - in to a mysql-db

Postby unleash_it » 01. July 2014 10:14

want to store the data - instead of printing out
there fore i set up a mysqldb on the suse
Code: Select all
import urllib
import urlparse
import re

url = "http://search.cpan.org/author/?W"
html = urllib.urlopen(url).read()
for lk, capname, name in re.findall('<a href="(/~.*?/)"><b>(.*?)</b></
a><br/><small>(.*?)</small>', html):
    alk = urlparse.urljoin(url, lk)

    data = { 'url':alk, 'name':name, 'cname':capname }

    phtml = urllib.urlopen(alk).read()
    memail = re.search('<a href="mailto:(.*?)">', phtml)
    if memail:
        data['email'] = memail.group(1)

    print data
unleash_it
 
Posts: 16
Joined: 10. December 2011 18:32
Operating System: linux opensuse 12.1

Re: store the data instead of printing it - in to a mysql-d

Postby unleash_it » 01. July 2014 16:21

while running this code i get the following results

Code: Select all

import urllib
import urlparse
import re

url = "http://search.cpan.org/author/?W"
html = urllib.urlopen(url).read()
for lk, capname, name in re.findall('<a href="(/~.*?/)"><b>(.*?)</b></
a><br/><small>(.*?)</small>', html):
    alk = urlparse.urljoin(url, lk)

    data = { 'url':alk, 'name':name, 'cname':capname }

    phtml = urllib.urlopen(alk).read()
    memail = re.search('<a href="mailto:(.*?)">', phtml)
    if memail:
        data['email'] = memail.group(1)

    print data



see the results...

Code: Select all
martin@linux-c5sz:~/perl> python cpan1.py
  File "cpan1.py", line 7
    for lk, capname, name in re.findall('<a href="(/~.*?/)"><b>(.*?)</b></
                                                                         ^
SyntaxError: EOL while scanning string literal
martin@linux-c5sz:~/perl>
unleash_it
 
Posts: 16
Joined: 10. December 2011 18:32
Operating System: linux opensuse 12.1


Return to Allerlei

Who is online

Users browsing this forum: No registered users and 2 guests