randomalbumtitle
randomalbumtitle

Reputation: 151

php scraping HTML - problems with IE only

I am scraping a website with HTML with php that retrieves a page and removes certain elements to only show a photo gallery. It works flawlessly for every browser BUT any version of IE (typical ;)). We can fix the problem by rewriting the .css file, but we cannot implement it into the head of the php as this will be overwritten by the .css file from the websites server. How would we go about hosting our own version of the .css file so that our website will be displayed using OUR version? Would be swap something out with a filter?

Cheers!

Upvotes: 0

Views: 161

Answers (4)

Syntax Error
Syntax Error

Reputation: 4527

This is just another thing to check, but if one of the elements you're removing is comments, you could unwittingly be pulling out ie only stylesheets that are between conditional comments. Another thing to look at is paths. Maybe one of their stylesheets has a relative path that you can't call from your server. You would need to make that an absolute path for it to work.

Really, you should probably take a close look at the source of the original page and your formatted source side by side. You could be pulling out something that's should be left in.

You ask how you could remove their css... you do it the same way you remove the other elements you're pulling out. Just pull out style tags and tags that link to stylesheets.

Aside from that I would just write some styles to fix it and stick it them anywhere after the existing css is called. (Like every one else here mentioned)

Upvotes: 2

Mawg
Mawg

Reputation: 40140

You do realize that it may not really be a scraping problem? It's sounds like a straightforward page display problem.

Worrying about scraping might be a red herring. After you have scraped you have some HTML (and possibly some CSS) ... does that validate at W3C? I realize that is no guarantee, but it is an indicator (I know that IE doesn't always display valid pages properly, but sometimes it's a "gotcha" when other browsers seem to display invalid HTML/CSS properly).

If it's valid then maybe you should look back at your scraping. If you already removes certain elements to only show a photo gallery then maybe you can also remove the CSS from the HTML header (or wherever) and reaplce it with your own?

Upvotes: 4

Pat
Pat

Reputation: 25675

If you're already scrapping the website, why not just use PHP to omit their CSS file and write your own in its place? Alternatively, you could write your own CSS file just below their's in the <head> so it overwrote their styles.

Upvotes: 3

Robus
Robus

Reputation: 8259

Just add another CSS header and mark your styles as !important to override the original ones?

Upvotes: 1

Related Questions