works on a python project, and he does this by looking at the lifehacker.com index, and then finds all the tags with the class "h5 hover-highlight entry-title", then he creates the files for each directory. But the only problem is that when I run it, I get OSError: [Errno 2] No such file or directory: "/home/root/python/The Sony Smartwatch 3: A Runner Perspective (Updated: 1/5/2015)"
help will be great, thanks!
heres my atm code:
import re import os import urllib2 from bs4 import BeautifulSoup from mechanize import Browser url = "http://lifehacker.com/" url_open = urllib2.urlopen(url) soup = BeautifulSoup(url_open.read()) link = soup.findAll("h1",{"class": "headline h5 hover-highlight entry-title"}) file_directory = "/home/root/python/" for i in link: os.mkdir(os.path.join(file_directory, str(i.text))) print "Successfully made directory(s)", i.text, "!" else: print "The directory", i.text, "either exists, or there was an error!"
source share