1

I have a wordpress site that has a plugin installed to scrape a weather reading from an external website, however, I don't like the graphics that site uses in the weather content.

I would like to know if there is a script that I can use to detect the path of the graphic and change it to the path I specify.

eg:

if image source (<img src="">) contains "http://resources.weatherzone.com.au/wz/images/icons/fcast_70/" then replace image source with "http://mywebsite.com/images/"

The thing is… the content changes with the weather, so the graphic may be dynamically updated. So I'd need to replace the path ONLY, leaving the image name the same.
Or… add an else section to keep the script going until it detects the full img src and replaces with my full image source.

I hope this makes sense and I look forward to a possible solution.

Thanks, Reece

1
  • Are there any other images in it you don't want to replace? Commented Nov 27, 2012 at 5:05

2 Answers 2

1

Try this

$("#imageId").attr("src", "your new url here");

Give some id to image & Afterwards you can change its source with jQuery.

Sign up to request clarification or add additional context in comments.

1 Comment

It would not be parsed by google and other search engines. OP's problem is a backend problem
0

Typically I'd approach something like this by loading the scraped HTML into PHP's DOMDocument, finding the image node on there, modifying it, and then writing back out the modified DOMDocument. For an example of how to use DOMDocument, see the first answer here: regexp to find image path file in an image tag

2 Comments

Wow, this is getting technical. The scraped html data is added to my site via a shortcode on a sidebar widget. The plugin used for the scraping is "WP Web Scrapper" Where would I call the DOMdocument code? In the sidebar.php template?
Yes, if that's where the plugin is used?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.