Answer the question
In order to leave comments, you need to log in
How to write a file parser on a website (Python)?
Good day, gentlemen and a few ladies!
The situation is this: we have a site URL and we need to find all the files on this site.
Question: what to use? Regular expressions ( '\.(php|txt|css)' )? Substitution method? How?
Thank you!
Answer the question
In order to leave comments, you need to log in
I used regular expressions (the module is called re). Specifically, I first received the page code:
from urllib import request
...
html = request.urlopen(your_url).read().decode('utf-8')
<tag1><div class='filenames'>имя файла.txt</div><br></tag1>
, then you can easily select the part of the text that matches the regexp that you need using parentheses.Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question