• 0

Retrieve IMDB rating


Question

I am writing a small script for a site that will take a movie name and retrieve the IMDB rating for that movie.

I am using the IMDB search to find the movie. This works fine.

$remote_url = "/find?q=" . $moviename;

IMDB works where if the movie title is original enough it will redirect you to the movies page and I am reading this redirect and going to the page fine with the following script.

	if (preg_match('/(Location:)(.*)/', $html)) {
		preg_match('/(Location:)(.*)/', $html, $array);
		$remote_url = $array[2];

If there is no automatic redirect I get a page of search results.

 else {
		preg_match('/<a href=\"\/title\/(.*)\/\">/i',$html,$array);

		$remote_url = "http://www.imdb.com/title/" . $array[1] . "/";
	}

I can use the above code to search for the first result.

Using Pirates of the Caribbean: At World's End as an example I am trying to find this code and retrieve only "tt0449088". This works fine so far.

1.</td><td valign="top"><img src="/images/b.gif" width="1" height="6"><br><a href="/title/tt0449088/">Pirates of the Caribbean: At World's End</a> (2007)<br>

The problem arises only on some movies where it finds different code.

<h2>Popular Results</h2> <p><b>Popular Titles</b> (Displaying 1 Result)<table><tr> <td valign="top"><a href="/title/tt1077258/" onClick="(new Image()).src='/rg/photo-find/title-tiny/images/b.gif?link=/title/tt1077258/';"><img src="https://ia.imdb.com/media/imdb/01/I/52/97/53/10t.jpg" width="23" height="32" border="0"></a> </td><td align="right" valign="top"><img src="/images/b.gif" width="1" height="6"><br>1.</td><td valign="top"><img src="/images/b.gif" width="1" height="6"><br><a href="/title/tt1077258/">Planet Terror</a> (2007)</td></tr></table> </p>

It will then return the tt1077258 plus all the on click and stuff like that. I have tried changing the preg_match so many times but I don't know how to use it very well so its more of a trial and error.

Any help would be much appreciated. or a better way of extracting the TT###### from the first result in the search...

Reference URLs:

http://imdb.com/find?s=all&q=Pirates.o...amp;x=0&y=0

http://imdb.com/find?s=all&q=Planet.Te...amp;x=0&y=0

Thanks,

--RAINMAN

Link to comment
https://www.neowin.net/forum/topic/613031-retrieve-imdb-rating/
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • OpenAI is now rolling out Lockdown Mode to more ChatGPT users by Pradeep Viswanathan Back in February, OpenAI first announced Lockdown Mode for users who want the most comprehensive protection from potential attacks. At the time of the announcement, the company mentioned that this feature was available to a small set of highly security-conscious users, including executives or security teams at leading organizations. Today, OpenAI announced that Lockdown Mode is now rolling out to all personal ChatGPT accounts, including Free, Go, Plus, and Pro, and also self-serve ChatGPT Business accounts. Users can enable the feature from ChatGPT Settings > Security when it is available for their account. When Lockdown Mode is enabled, ChatGPT limits or disables several features that connect to the web or external services. These include live web browsing, Deep Research, Agent Mode, and more. Here is the complete list of services that will be disabled in Lockdown Mode: Live web browsing: Web browsing is limited to accessing only cached content. Search results may be limited, unavailable, or stale. Image support: ChatGPT may not display images in regular responses or retrieve images from the web. Users can still upload image files, and image generation remains available where it is otherwise available. Deep research: Deep research is disabled. Agent mode: Agent mode is disabled. Canvas networking: Users cannot approve Canvas-generated code to access the network. File downloads: ChatGPT cannot download files for data analysis. ChatGPT can still operate on your manually uploaded files. It is important to note that Lockdown Mode does not completely block prompt injections from appearing in content that ChatGPT processes. For example, a malicious instruction could still be present in an uploaded file or cached web content. However, the mode is designed to reduce the ways such an attack could send sensitive information outside the conversation. Along with Lockdown Mode, OpenAI today also announced that the Active sessions feature is now available across ChatGPT accounts and workspace types. This feature allows users to review where their account is signed in across devices and end sessions if required. A session will have the following information displayed: Device or browser information. First-party app context, such as ChatGPT, Codex, or API Platform. Approximate location. Sign-in date and time. Whether the device is a trusted device. Whether it is your current session. OpenAI highlighted that the Active sessions feature will not be available for accounts linked to an organization’s single sign-on setup, including SAML or OIDC.
    • with LSTC and ESU, moving to w11 or linux because w10 suddenly will not work when in reality it works and its a better choice, of course there are also developers that only test in 11 or force you to have TPM and Secure boot for the sake of "better security" in games. or most likely people is buying new PC that only ship with 11
    • with LTSC and ESU there are still viable as a stable platform not that they care and let people deal with w11 crashing and burning every month support mean shet if the platform is trash
    • Most boring game ever. Repetitive, empty, predictable, and full of cliches. Total waste of time and money, IMO.
  • Recent Achievements

    • Rookie
      moog19 went up a rank
      Rookie
    • Mentor
      grik went up a rank
      Mentor
    • Dedicated
      JKR earned a badge
      Dedicated
    • One Year In
      CHUNWEI earned a badge
      One Year In
    • Conversation Starter
      FBSPL earned a badge
      Conversation Starter
  • Popular Contributors

    1. 1
      +primortal
      487
    2. 2
      PsYcHoKiLLa
      270
    3. 3
      Skyfrog
      75
    4. 4
      Steven P.
      68
    5. 5
      FloatingFatMan
      63
  • Tell a friend

    Love Neowin? Tell a friend!