Hi.
With using file_get_contents()
I can get all html tags and text of a web page. But is there any way to get that web page's css codes too?
Niloofar24
15
Posting Whiz
Recommended Answers
Jump to PostUse DOMDocument and loop through <link> tags. With the fragmentation of styling rules (CSS, inline styling, style tags, js-delivered styling) it may be more difficult than you may think.
Jump to Postanother option that will give you a total control is php html DOM parser API.
for example,
$scrape = file_get_html('somesite_to_scrape.com'); /* get the css line */ foreach($scrape->find('link.href') as $css_file){ /* this is the css file location */ $css_file; }
you can also do …
Jump to Posti have downloaded php html DOM parser API zip folder
Have you installed it into a folder of your choice and included it in the file where you wish to use it?
Extract the file:
simple_html_dom.php
to where you want e.g. 'vendors'
Include it in your file …
Jump to PostAm sure the next thing is "I need the images and downloads in all links too". Why not use a tool like
wget
, you can call it if you have execute rights on your system, and it will download anything it can find, you specify how deep it should go.
All 15 Replies
diafol
Niloofar24
15
Posting Whiz
diafol
lorenzoDAlipio
24
Junior Poster in Training
lorenzoDAlipio
24
Junior Poster in Training
diafol
TexWiller
0
Newbie Poster
Niloofar24
15
Posting Whiz
TexWiller
0
Newbie Poster
Niloofar24
15
Posting Whiz
diafol
pritaeas
2,194
¯\_(ツ)_/¯
Moderator
Featured Poster
Niloofar24
15
Posting Whiz
TexWiller
0
Newbie Poster
diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.