问题
i need something written in javascript or jquery that copy a content of a page (for example there is a page with a html table in which there are lot of fields about the weather in my city, i'd like to copy the fields (morning: 10°C, afternoon: 15°C, evening: 11°C), in a web page i'll create). Obviusly that fields have to be reloaded every X minutes (for example 30 minutes) because the fields with the weather are reloaded every X minutes in their database.
I hope my english is not to much bad, so you could help me in this problem. Thank yall!
回答1:
I guess what you are asking about is web Scraping.
There is a Javascript framework to handle this called PJScrape, there may be others and a G* search should help you.
There is also a question regarding simple scraping here on stackexchange.
回答2:
You can't do this with JavaScript because of Same Origin Policy. You need to download this page with PHP and then parse your values. You can use for example PHP Simple HTML DOM Parser to work with downloaded page like with JavaScript (there are examples on their site so i dont append example code here)...
来源:https://stackoverflow.com/questions/16055423/javascript-which-copy-content-which-is-into-a-html-div-into-another-page-created