Extracing CSS/JSS from a given URL

76 views Asked by At

Currently trying to write a python script that can extract the CSS/JSS from a given URL. Had stumbled across urllib3 which helped me collect the HTML of a given URL with the help of their PoolManager() utility. With the short code below, I was able to extract the HTML of the given URL and later on store it in a file.

import urllib3
http = urllib3.PoolManager()
x = http.request('GET','www.something.com')
x.data

I had gone through the documentation for urllib3 on their official page. However, there wasn't too much on the various functions that was coming close to what I'm searching for. Now I need to somehow get the external resources of a particular URL and I'd like to know if it's possible using urllib3 or whether I need to search for something else that'll help me do the same (any suggestions are welcomed as well).

Thanks in advance everyone!

1

There are 1 answers

0
Daniel Roseman On

This isn't something you'd do with urllib3. Once you've got the HTML, you have to parse it and extract the elements that link to CSs and JS files. You can use BeautifulSoup for that.