I'm trying to load the ratings, used in this Google website, in my own page.
http://www.google.com/maps/place?source=uds&q=restaurants&cid=10470472694367837337
I'd like to show the ratings on my own website, so just loading the ratings-DIV would do the trick.
Any ideas?
You could use PHP (or another backend language) to crawl that page, extracting the div, then pass it to the website.
However, seeing how the ratings come from google, I'd suggest you take a look if there isn't some google API you can use to get the ratings. I don't know what API you can use from mind but this should help you out with that.
http://code.google.com/intl/nl-NL/more/table/
Get the page and parse it.
For PHP you could use http://www.phpclasses.org/package/3086-PHP-Parse-and-extract-information-from-HTML-using-SQL.html to parse it in a SQL style.
You shouls use the places api google provide. Its a webservice that returns information on places and locations. You will need a google account and to setup a api key which you can do here
You can then call this api from client or server side code. The place details results of the place Details api call returns a rating.
You should not just extract html content from another sites webpage!
You can use PHP Simple HTML DOM Parser http://simplehtmldom.sourceforge.net/
$html = file_get_html('http://www.google.com/maps/place?source=uds&q=restaurants&cid=10470472694367837337');
foreach ($html -> find('div.rsw-stars') as $element)
print count($element -> find('.rsw-starred')) . '<br>';
Related
I would like to extract specific data from a webpage then open a specific webpage based on what that data is. In the form of an if statement.
Say for example I google the olympics (https://www.google.com/#safe=off&hl=en&q=olympics&btnK=Google+Search)
It says it is in "Rio" right now. Say based on "Rio" I have a link that directs to Wikipedia and if it said something other than "Rio" it directs to www.google.com. I need to find a way to be able to pinpoint the data I need from another webpage then make a decision based off of that. The hard part being assigning that data to a variable.
I would like to do this in jQuery if at all possible. If not what language what I need to do this? Is there a specific name for this type of thing (pulling data off of webpages) and are there any resources so I can learn more about it?
Thank you
I think its what you are looking for. Correct me if i'm wrong
You can use the PHP method on a file called go.php
<?echo get_file_contents($_GET['a']); ?>
and call it from AJAX using:
$.get("go.php?a=https://google.com", function(data){
//Your code....
});
IMPORTANT: DON'T FORGET THE HTTP OR HTTPS, if you forget it, go.php will try to find google.com in your server.
This method doesn't load the images because it tries to load them from your server
I have used php simple html dom to no success on this issue.
Now I have gone to DOMDocument and DOMXpath and this does seem promising.
Here is my issue:
I am trying to scrape data from a page which is loaded via a web service request after the page initially shows. It is only milliseconds but because of this, normal scraping shows a template value as opposed to the actual data.
I have found the endpoint url using chrome developer network settings. So if I enter that url into the browser address bar the data displays nicely in JSON format. All Good.
My problem arises because any time the site is re-visited or the page refreshed, the suffix of the endpoint url is randomly-generated so I can't hard-code this url into my php file. For example the end of the url is "?=253648592" on first visit but on refresh it could be "?=375482910". The base of the url is static.
Without getting into headless browsers (I tried and MY head hurts!) is there a way to have Xpath find this random url when the page loads?
Sorry for being so long-winded but I wanted to explain as best I could.
It's probably much easier and faster to just use a regex if you only need one item/value from the HTML. I would like to give an example but therefor I would need a more extended snippet of how the HTML looks like that contains the endpoint that you want to fetch.
Is it possible to give a snippet of the HTML that contains the endpoint?
Is there any way to take the list of available positions for a company from JobVite using javascript (I would prefer if it returned JSON)?
I would like to take 5 random open position and display them in a recruiting region on the website I am working on.
I can confirm that Jobvite DOES have an API, and it returns results in JSON! You need to submit a request to obtain an API key. (Look in the Category dropdown menu)
http://recruiting.jobvite.com/support/customer
Yes. You'll need an API key and secret as blastronaut points out. Then hit this URL:
https://api.jobvite.com/v1/jobFeed?api=KEY&sc=SECRET&companyId=COMPANYID
The API documentation is here: Jobvite Services API PDF
Well, if they have no API, I guess you're going to need to use cURL or something similar and then your PHP could return JSON encoded results?
Failing that, you might check out:
https://github.com/dylang/jobvite
To document some recent events I saved all tweets including a special hashtag. Now I have about 50.000 tweets which I want to publish. To save bandwidth and server load I want just want to send the raw tweet text to the client and then render it with javascript (linking hashtags, useranames and urls).
Is there already javascript library which is able to parse and create a html representation from a raw tweet?
twitterlib.render() looks like a good start... assuming you have parsed JSON tweet data:
<script src="twitterlib.js"></script>
<script>
var parsed_tweet_data = getTweetData(...); // get a Tweet JS object...
var html = twitterlib.render(parsed_tweet_data);
// Do something with the rendered html now...
</script>
Here's a twitterlib walkthrough on SlideShare.net (slide 17 has a demo.)
Have you considered using the Twitter oembed API? It basically lets you request the "official" embedded tweet HTML programmatically using an anonymous API (no authentication required). This would at least make it easy to meet the display requirements without reinventing the wheel. You can even do this client side, depending on your use case.
I'm grappling with this same issue, so let us know what you try and how it works for your project.
We're doing a simple implementation of Google Analytics on our ASP.NET with jQuery/AJAX web, and for most of it we just call _trackPageview and let Google do the rest.
We do a lot of data transfer in query strings, and recently, management became concerned that a lot of our data (such as product numbers) would be sent to Google. Without discussing whether that should be a concern:
Is it possible to use Google Analytics at all without sending the query string to Google's servers? I know how to filter it out from the actual reports, but I'm looking for a way to prevent it from being sent over the wire at all.
Yes, as Litso said, you can send a whatever you want as the pathname for a GA page-view, but you'll want to automate the process with JavaScript.
The following code will take the current URL's pathname (which excludes the query string) and uses it as the pagename value.
_gaq.push(['_trackPageview', location.pathname ]);
Or, conversely, if you're using the old _gat code,
pageTracker._trackPageview(location.pathname);
So, if your URL is http://example.com/path/to/page.html?supersecretinfo, it will get tracked in GA as /path/to/page.html
In stead of automatically tracking the pageview, you can use
pageTracker._trackPageview('/dir/example.html');
You'll have to dynamically strip out the parameters off of the url of each page. I'm not sure how to do that but it's definitely possible with JavaScript.