Let me state this by saying that I am not quite sure what is going on with my code; I am new to programming.
I am working on creating a separate final project for my python CS class, which checks my teacher website daily and determines if it has changed any web pages on its website since the last time the program was launched or not.
The step I'm currently working on is as follows:
def write_pages_files(): ''' Writes the various page files from the website links ''' links = get_site_links() for page in links: site_page = requests.get(root_url + page) soup = BeautifulSoup(site_page.text) with open(page + ".txt", mode='wt', encoding='utf-8') as out_file: out_file.write(str(soup))
The links look something like this:
/ site / site_name / class / final code
And the error I get is as follows:
with open(page + ".txt", mode='wt', encoding='utf-8') as out_file: FileNotFoundError: [Errno 2] No such file or directory: '/site/sitename/class.txt'
How to write site pages with these types of names (/site/sitename/nameofpage.txt)?
cody.codes
source share