Is der any method to read the Google search result and display it own style . I want to read the contents of Google search results after users search for query will display only the .PDF files for the search queries is it possible to do with PHP ?
Yes, by using Google's public search API.
Like Bart mentioned you can and should use the API so as be on the up and up with Google.
But that being said if you want to really have a hack you can just make a curl request from php to do the search against google and parse the results. Or you could even do it in perl and just run the perl script from php.
But again this is not the preferred solution. I am just trying to provide an answer for your question. And yes it can be done.
Related
Is it possible to scrap the web based on Keywords using Search engines in PHP?
Like when some put keyword, the script will search google and render the results and then render the pages and scrap/extract the line that includes the matched keywords?
Any idea or library to refer to?
You can do that using google api https://developers.google.com/custom-search/json-api/v1/overview and a related php client https://github.com/google/google-api-php-client.
Later on you need to write a web scraper to download the websites (curl) and parse the html parser (i.e. https://github.com/paquettg/php-html-parser).
I would, however, not recommend php for the latter task. There are much more sophisticated scraping tools available for python (i.e. BeautifulSoup or Scrapy) that will make your life much MUCH easier than using php.
You can use php function call
file_get_contents('web url goes here');
example file_get_contents('http://www.google.com');
That function will get the html returned from the url, then you can use xpath to extract the element of html to get the data that you want.
You can see example and more explanation url below.
https://gist.github.com/anchetaWern/6150297
I personally have done something similar of your question, but it's in ruby on rails, you can explore the project here.
https://github.com/dvarun/gextract
the xpath that I used is here:
https://github.com/dvarun/gextract/blob/master/app/jobs/fetch_keyword_job.rb
I'm using simple twitter API on php 7.1.
I'm trying to tweets which has both hashtags: #hashtag1 and #hashtag2.
On some question on this site I read about AND and OR. I'm trying AND, but it doesn't work.
Any idea? I read all twitter documentation, but find nothing.
I'm not sure what PHP library you are using, but this works against the API directly, using the twurl tool.
twurl "/1.1/search/tweets.json?q=%23snow%20AND%20%23ice&tweet_mode=extended"
I have made a crazy (?) thought right now...
Is there any script written in PHP that gets a given keyword and returns a url of a relative image? (from google, yahoo, etc)
If so, may I have an example? And if not, hwo can this be made?
Thanks!!
You can use the Flicker API. phpFlickr seems to be an existing PHP library.
You can try the PHP's CURL functions to do that, just google it and read the PHP manual.
Try this one
Demo : http://www.scriptbaba.com/demos/get_images/
http://www.scriptbaba.com/details-php-image-search-api-25.html
Trying to learning some more PHP. Here is what I'm after.
Essentially, I would like to search a website and return data to my own website.
Add a few keywords to a form.
Use those keywords to query a website such as monster.com for results that match the keywords entered.
Grab that data and return it to my own website.
How hard is something like this? I acknowledge the above outline is oversimplified but any tips you can offer are much appreciated.
If you're querying a site that has an API designated for this kind of functionality, you're on easy street. Just call the API's appropriate search function and you're all set.
If the site you're querying doesn't have an API, you still might be able to search the site with an HTTP GET using the right parameters. Then you just need to scrape through the file for the search results with your script and a few regex functions.
Here's a little tutorial on screen scraping with PHP. Hopefully that will be of some help to you. The trouble with this is that in general if the site hasn't made it easy to access their data, they might not want you to do this.
Enter Yahoo Query Language (yql). It's a service that let's you use things like xpath to get data from websites and put them into an easy to use xml or json format. The language is similarly structured to sql (hence the name).
I've used it for other sites to build rss feeds for sites that didn't have it and it was pretty easy to learn.
http://developer.yahoo.com/yql/
I have set up 'Nutch search engine' to crawl websites.
Now,I need to write an php API to talk to the Nutch search engine.
I need to do 2 things:
using a PHP script I need to specify to Nutch as to which URLs to crawl
(for this I have some pointers from http://www.cs.sjsu.edu/faculty/pollett/masters/Semesters/Fall07/sheetal/?Deliverable2.html
using a PHP script I need to retrieve the crawl result from the Nutch crawl DB.
I cant seem to find any help on this (or I might be too dumb to see the answer if it's already there :()
If anyone has used a PHP API to read Nutch crawl results, please share some pointers with me.
Desperately waiting for some help.
I'm looking for a real good way to do this too. But as of now, Im using a JSP API to display search results.
This should start you off.
You could alternatively use php to recieve your results as JSON objects.
To kick you off in this direction, there's a interesting page to get you started on JSON using jquery.
Google for other tutorials on JSON. There are plenty of'em.
for your question #1 you need to inject these URLs to the crawler. Relatively simple :
+ create a file with the URLs you want added
+ issue inject command with these URL's (may need to wait for the end of the previous crawl/fetch/index cycle)
+ start a new crawl
note : you need to make sure the urls are not filtered out as well
you need to use solr for search or another search platform, nutch is just a crawler, the idea is simple :
==> nutch for crawling
==> solr to create an index
==> build an interface to search inside the index( step 2). i used
SolariumBundleā€ˇ for this step
regarding #2, Nutch is written in JSP & Java, I don't know any PHP implementation (if you find I'm interested).
So basically you weed to create an AJAX or SOAP kind of communication scheme between your PHP script and the Nutch Server.
Have you tried the nutch mailing list for help ?