0

So basically this has been asked many times but I couldn't find an answer with my needs. Basically I have found many urls with links like example.com/ajax/search?query=Thing

I have a bit of a header in the works and I currently use W3schools XML version but it doesn't fit my needs at all since I need it to basically search IMDB for whatever the user enters, Once they enter for example 'The Simpsons' it will then popup all search results with the name and it being a clickable link to the IMDB link for example http://www.imdb.com/title/tt0096697/ but then replace imdb.com in that url with my websites url (To make it responsive in a way).

But I need it to use AJAX/jQuery in a way so that it searches on IMDB so using this XML file method wont work.

How is the sites with /ajax/search doing this type of IMDB search which is used a lot on torrenting sites lately.

This is where I got my current code for the search from: Live search with PHP AJAX and XML

But as I said it needs to be run with Ajax, Have live search, and basically scrape/search on IMDB in a way and then change imdb.com to mysite.com

Update: I managed to find something like this: http://pastebin.com/PAD5AXUK

And this is the HTML:

<div class="main-nav-links hidden-sm hidden-xs">
            <form method="GET" action="http://www.imdb.com/find" accept-charset="UTF-8" id="quick-search" name="quick-search">
                <div id="quick-search-container">
                    <input id="quick-search-input" name="query" autocomplete="off" value="Quick search" type="search">
                    <div style="background-position: -160px 0px;" class="ajax-spinner"></div>
                </div>
            </form>
            <ul class="nav-links">
                <li> <a href="https://example.com"> Home </a> 
                </li>
                <li> <a href="https://example.com/browse"> Browse </a> 
                </li>
            </ul>
            <ul class="nav-links nav-link-guest">
                <li> <a class="login-nav-btn" href="javascript:void(0)"> Login </a> &nbsp;|&nbsp; <a class="register-nav-btn" href="javascript:void(0)"> Register </a> 
                </li>
            </ul>
        </div>

But it still doesnt seem to work at all

Community
  • 1
  • 1
Kyubeh2435436
  • 123
  • 1
  • 7

2 Answers2

0

you can check this. https://twitter.github.io/typeahead.js/ Problem will be solved

0

As for the searching of IMDB You're going to have to use something like the php curl extension to get the contents from the website and parse them with an html parser library.

For the live searching thing, you can change the url in javascript with this pushState() function like in the following answer: Changing the url with javascript. Then you can use some jQuery to make it easier to send ajax get requests to YOUR OWN server, where the php script will process the request to IMDB (something involving

$.get("/ajax?query=TMNT", function(data) { //handle the data in here } );

Then in that callback function you can update your page with the contents of the result. You could even do some of the processing locally, like with the changing the url of the IMDB link.

The process would resemble the following chart:

User Enters Query (TMNT) -> 
Ajax sends data to my own backend page (process.php) -> 
process.php scrapes IMDB search query and parses it with html parser -> 
outputs results which return to ajax function -> 
ajax callback function places results in a DOM element
Community
  • 1
  • 1
Micaiah Wallace
  • 1,101
  • 10
  • 17
  • All that is a really slow and over complicated way of doing this. THere is definitely a much faster way of doing this ty doe. – Kyubeh2435436 Jun 29 '15 at 22:47
  • @Kyubeh2435436, the only faster way would be directly with javascript ajax calls to the IMDB server, but CORS isn't going to let you do that if you plan to release it to the public. Unless, the IMDB website has an API – Micaiah Wallace Jun 29 '15 at 22:59
  • @Kyubeh2435436 It looks like here, that they use their own API http://stackoverflow.com/questions/1966503/does-imdb-provide-an-api which you might be able to tap into, but it might still have a Cross-Origin block for other websites besides themselves – Micaiah Wallace Jun 29 '15 at 23:02