movie id tt0438097 can be found at http://www.imdb.com/title/tt0438097/
电影ID tt0438097可以在http://www.imdb.com/title/tt0438097/找到
What's the url for its poster image?
它的海报图片的网址是什么?
15 个解决方案
#1
9
As I'm sure you know, the actual url for that image is
我相信你知道,该图像的实际网址是
You're going to be hard pressed to figure out how it's generated though and they don't seem to have a publicly available API.
你将很难弄清楚它是如何生成的,它们似乎没有公开的API。
Screenscraping is probably your best bet.
屏幕抓取可能是你最好的选择。
The picture seems to generally be inside a div with class=photo and the name of the a tag is poster.
图片似乎通常位于带有class = photo的div内,而a标签的名称是海报。
The image itself is just inside the a tag.
图像本身就在标签内部。
#2
16
Check out http://www.imdbapi.com/, It returns Poster url in string.
查看http://www.imdbapi.com/,它返回字符串中的海报网址。
For example, check http://www.imdbapi.com/?i=&t=inception and you'll get the poster address: Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SX320.jpg"
例如,检查http://www.imdbapi.com/?i=&t=inception,您将获得海报地址:海报“:”http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw @@ ._ V1._SX320.jpg”
Update: Seems like the site owner had some arguments with IMDB legal staff. As mentioned in the original site, new site's address is http://www.omdbapi.com/
更新:似乎网站所有者与IMDB法律人员有一些争论。如原始网站所述,新网站的地址是http://www.omdbapi.com/
#3
5
The URL is a random string as far as I can tell.
据我所知,URL是一个随机字符串。
It can still be easily retrieved. It is the only img
inside the anchor named poster
.
它仍然可以轻松检索。它是名为poster的锚中唯一的img。
So, if you are reading the source, simply search for <a name="poster"
and it will be the text following the first src="
from there.
However, you will need to keep the screen scraping code updated because that will probably change.
但是,您需要更新屏幕抓取代码,因为这可能会更改。
You should also be aware that the images are copyrighted, so be careful to only use the image under a good "fair use" rationale.
您还应该知道图像是受版权保护的,因此请务必仅在良好的“合理使用”原理下使用图像。
#4
5
If a thumb is enough, you can use the Facebook Graph API: http://graph.facebook.com/?ids=http://www.imdb.com/title/tt0438097/
如果拇指足够,您可以使用Facebook Graph API:http://graph.facebook.com/ ?ids = http://www.imdb.com/title/tt0438097/
Gets you a thumbnail: http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg
获取缩略图:http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg
#5
5
I know that it is way too late, but in my project I used this:-
我知道这太晚了,但在我的项目中我使用了这个: -
- Use omdbapi, Lets take example of Inception, use www.omdbapi.com/?t=inception it will return a json object.
- In that json object get the "Poster" object, it contains the poster for the image.
使用omdbapi,让我们以Inception为例,使用www.omdbapi.com/?t=inception它将返回一个json对象。
在json对象中获取“Poster”对象,它包含图像的海报。
#6
3
omdbapi works, but I found out you cannot really use these images (because of screen scraping and they are blocked anyway if you use them in an img tag)
omdbapi有效,但我发现你不能真正使用这些图像(因为屏幕抓取,如果你在img标签中使用它们,它们会被阻止)
The best solution is to use tmdb.org :
最好的解决方案是使用tmdb.org:
1 use your imdbid in this api url:
1在这个api url中使用你的imdbid:
https://api.themoviedb.org/3/find/tt0111161?api_key=___YOURAPIKEY___&external_source=imdb_id
2 Retrieve the json response and select the poster_path
attribute:
2检索json响应并选择poster_path属性:
"poster_path":"/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg"
3 Prepend this path with "http://image.tmdb.org/t/p/original"
, and you will have the poster URL that you can use in an img tag :-)
3在此路径前加上“http://image.tmdb.org/t/p/original”,您将获得可在img标签中使用的海报网址:-)
4 You can even change sizes like this:
4您甚至可以更改这样的大小:
http://image.tmdb.org/t/p/original/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
http://image.tmdb.org/t/p/w150/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
#7
2
You can use imdb-cli
tool to download movie's poster, e.g.
您可以使用imdb-cli工具下载电影的海报,例如
omdbtool -t "Ice Age: The Meltdown" | wget `sed -n '/^poster/{n;p;}'`
#8
1
Be aware tough, that the terms of service explicitly forbid screenscraping. You can download the IMDB database as a set of text files, but as I understand it, the IMDB movie ID is nowhere to be found in these text files.
请注意严格,服务条款明确禁止屏幕抓取。您可以将IMDB数据库下载为一组文本文件,但据我了解,这些文本文件中找不到IMDB电影ID。
#9
1
You can use Trakt API, you have to make a search request with the imdb ID, and the Json result given by Trakt API contains links for two images of that movie (poster and fan art) http://trakt.tv/api-docs/search-movies
您可以使用Trakt API,您必须使用imdb ID发出搜索请求,并且Trakt API提供的Json结果包含该电影的两个图像的链接(海报和粉丝艺术)http://trakt.tv/api-文档/搜索电影
#10
1
I've done something similar using phantomjs and wget. This bit of phantomjs accepts a search query and returns the first result's movie poster url. You could easily change it to your needs.
我使用phantomjs和wget做了类似的事情。这个phantomjs接受搜索查询并返回第一个结果的电影海报网址。您可以轻松地将其更改为您的需求。
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: moviePoster.js <movie name>');
phantom.exit();
}
var formattedTitle = encodeURIComponent(system.args[1]).replace(/%20/g, "+");
var page = require('webpage').create();
page.open('http://m.imdb.com/find?q=' + formattedTitle, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $(".title").first().find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $("#img_primary").find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return $(".photo").first().find('img').attr('src');
});
console.log(url);
page.close();
phantom.exit();
});
});
});
I download the image using wget for many movies in a directory using this bash script. The mp4 files have names that the IMDB likes, and that's why the first search result is nearly guaranteed to be correct. Names like "Love Exposure (2008).mp4".
我使用wget为使用此bash脚本的目录中的许多电影下载图像。 mp4文件具有IMDB喜欢的名称,这就是为什么第一个搜索结果几乎保证是正确的。名字如“Love Exposure(2008).mp4”。
for file in *.mp4; do
title="${file%.mp4}"
if [ ! -f "${title}.jpg" ]
then
wget `phantomjs moviePoster.js "$title"` -O "${title}.jpg"
fi
done
Then minidlna uses the movie poster when it builds the thumbnail database, because it has the same name as the video file.
然后minidlna在构建缩略图数据库时使用电影海报,因为它与视频文件具有相同的名称。
#11
1
$Movies = Get-ChildItem -path "Z:\MOVIES\COMEDY" | Where-Object {$_.Extension -eq ".avi" -or $_.Extension -eq ".mp4" -or $_.Extension -eq ".mkv" -or $_.Extension -eq<br> <br>".flv" -or $_.Extension -eq ".xvid" -or $_.Extension -eq ".divx"} | Select-Object Name, FullName | Sort Name <br>
#Grab all the extension types and filter the ones I ONLY want <br>
<br>
$COMEDY = ForEach($Movie in $Movies) <br>
{<br>
$Title = $($Movie.Name)<br>
#Remove the file extension<br>
$Title = $Title.split('.')[0] <br>
<br>
#Changing the case to all lower <br>
$Title = $Title.ToLower()<br>
<br>
#Replace a space w/ %20 for the search structure<br>
$searchTitle = $Title.Replace(' ','%20') <br>
<br>
#Fetching search results<br>
$moviesearch = Invoke-WebRequest "http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"<br>
<br>
#Moving html elements into variable<br>
$titleclassarray = $moviesearch.AllElements | where Class -eq 'title' | select -First 1<br>
<br>
#Checking if result contains movies<br>
try<br><br>
{
$titleclass = $titleclassarray[0]<br>
}<br>
catch<br>
{<br>
Write-Warning "No movie found matching that title http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"<br>
} <br>
<br>
#Parcing HTML for movie link<br>
$regex = "<\s*a\s*[^>]*?href\s*=\s*[`"']*([^`"'>]+)[^>]*?>"<br>
$linksFound = [Regex]::Matches($titleclass.innerHTML, $regex, "IgnoreCase")<br>
<br><br>
#Fetching the first result from <br>
$titlelink = New-Object System.Collections.ArrayList<br>
foreach($link in $linksFound)<br>
{<br>
$trimmedlink = $link.Groups[1].Value.Trim()<br>
if ($trimmedlink.Contains('/title/'))<br>
{<br>
[void] $titlelink.Add($trimmedlink)<br>
}<br>
}<br>
#Fetching movie page<br>
$movieURL = "http://www.imdb.com$($titlelink[0])"<br>
<br>
#Grabbing the URL for the Movie Poster<br>
$MoviePoster = ((Invoke-WebRequest –Uri $movieURL).Images | Where-Object {$_.title -like "$Title Poster"} | Where src -like "http:*").src <br>
<br>
$MyVariable = "<a href=" + '"' + $($Movie.FullName) + '"' + " " + "title='$Title'" + ">"<br>
$ImgLocation = "<img src=" + '"' + "$MoviePoster" + '"' + "width=" + '"' + "225" + '"' + "height=" + '"' + "275" + '"' + "border=" + '"' + "0" + '"' + "alt=" +<br> '"' + $Title + '"' + "></a>" + " " + " " + " "+ " " + " " + " "+ " " + " " + " "<br>
<br>
Write-Output $MyVariable, $ImgLocation<br>
<br>
}$COMEDY | Out-File z:\db\COMEDY.htm <br>
<br>
$after = Get-Content z:\db\COMEDY.htm <br>
<br>
#adding a back button to the Index <br>
$before = Get-Content z:\db\before.txt<br>
<br>
#adding the back button prior to the poster images content<br>
Set-Content z:\db\COMEDY.htm –value $before, $after<br>
#12
0
Those poster images don't appear to have any correlation to the title page, so you'll have to retrieve the title page first, and then retrieve the img element for the page. The good news is that the img tag is wrapped in an a tag with name="poster". You didn't say what kind of tools you are using, but this basically a screen scraping operation.
这些海报图像似乎与标题页没有任何关联,因此您必须先检索标题页,然后检索页面的img元素。好消息是img标签包含在一个名为=“poster”的标签中。你没有说你正在使用什么样的工具,但这基本上是一个屏幕抓取操作。
#13
0
Here is my program to generate human readable html summary page for movie companies found on imdb page. Change the initial url to your liking and it generates a html file where you can see title, summary, score and thumbnail.
这是我的程序,为imdb页面上的电影公司生成人类可读的html摘要页面。根据您的喜好更改初始网址,它会生成一个html文件,您可以在其中查看标题,摘要,分数和缩略图。
npm install -g phantomjs
Here is the script, save it to imdb.js
这是脚本,将其保存到imdb.js
var system = require('system');
var page = require('webpage').create();
page.open('http://www.imdb.com/company/co0026841/?ref_=fn_al_co_1', function() {
console.log('Fetching movies list');
var movies = page.evaluate(function() {
var list = $('ol li');
var json = []
$.each(list, function(index, listItem) {
var link = $(listItem).find('a');
json.push({link: 'http://www.imdb.com' + link.attr('href')});
});
return json;
});
page.close();
console.log('Found ' + movies.length + ' movies');
fetchMovies(movies, 0);
});
function fetchMovies(movies, index) {
if (index == movies.length) {
console.log('Done');
console.log('Generating HTML');
genHtml(movies);
phantom.exit();
return;
}
var movie = movies[index];
console.log('Requesting data for '+ movie.link);
var page = require('webpage').create();
page.open(movie.link, function() {
console.log('Fetching data');
var data = page.evaluate(function() {
var title = $('.title_wrapper h1').text().trim();
var summary = $('.summary_text').text().trim();
var rating = $('.ratingValue strong').attr('title');
var thumb = $('.poster img').attr('src');
if (title == undefined || thumb == undefined) {
return null;
}
return { title: title, summary: summary, rating: rating, thumb: thumb };
});
if (data != null) {
movie.title = data.title;
movie.summary = data.summary;
movie.rating = data.rating;
movie.thumb = data.thumb;
console.log(movie.title)
console.log('Request complete');
} else {
movies.slice(index, 1);
index -= 1;
console.log('No data found');
}
page.close();
fetchMovies(movies, index + 1);
});
}
function genHtml(movies) {
var fs = require('fs');
var path = 'movies.html';
var content = Array();
movies.forEach(function(movie) {
var section = '';
section += '<div>';
section += '<h3>'+movie.title+'</h3>';
section += '<p>'+movie.summary+'</p>';
section += '<p>'+movie.rating+'</p>';
section += '<img src="'+movie.thumb+'">';
section += '</div>';
content.push(section);
});
var html = '<html>'+content.join('\n')+'</html>';
fs.write(path, html, 'w');
}
And run it like so
然后像这样运行它
phantomjs imdb.js
#14
0
$Title = $($Movie.Name)
$searchTitle = $Title.Replace(' ','%20')
$moviesearch = Invoke-WebRequest "http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"
$titleclassarray = $moviesearch.AllElements | where Class -eq 'loadlate' | select -First 1
$MoviePoster = $titleclassarray.loadlate
#15
-2
Now a days, all modern browser have "Inspect" section:
现在有一天,所有现代浏览器都有“Inspect”部分:
100% Correct for Google Chrome only:
仅适用于Google Chrome的100%正确:
- Take your cursor on image.
- Right click on it, select "Inspect Element".
- In the window appear, under Elements tab you will find the highlighted text as
- Just click on it.
- In the Resource tab, right click on image.
- Select "Copy image URL" option.
将光标放在图像上。
右键单击它,选择“Inspect Element”。
在窗口中,在“元素”选项卡下,您将找到突出显示的文本
只需点击它。
在“资源”选项卡中,右键单击图像。
选择“复制图像URL”选项。
Try to paste it any where as URL in any browser, you will only get the image.
尝试将其粘贴到任何浏览器中作为URL的位置,您将只获取图像。
#1
9
As I'm sure you know, the actual url for that image is
我相信你知道,该图像的实际网址是
You're going to be hard pressed to figure out how it's generated though and they don't seem to have a publicly available API.
你将很难弄清楚它是如何生成的,它们似乎没有公开的API。
Screenscraping is probably your best bet.
屏幕抓取可能是你最好的选择。
The picture seems to generally be inside a div with class=photo and the name of the a tag is poster.
图片似乎通常位于带有class = photo的div内,而a标签的名称是海报。
The image itself is just inside the a tag.
图像本身就在标签内部。
#2
16
Check out http://www.imdbapi.com/, It returns Poster url in string.
查看http://www.imdbapi.com/,它返回字符串中的海报网址。
For example, check http://www.imdbapi.com/?i=&t=inception and you'll get the poster address: Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1._SX320.jpg"
例如,检查http://www.imdbapi.com/?i=&t=inception,您将获得海报地址:海报“:”http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw @@ ._ V1._SX320.jpg”
Update: Seems like the site owner had some arguments with IMDB legal staff. As mentioned in the original site, new site's address is http://www.omdbapi.com/
更新:似乎网站所有者与IMDB法律人员有一些争论。如原始网站所述,新网站的地址是http://www.omdbapi.com/
#3
5
The URL is a random string as far as I can tell.
据我所知,URL是一个随机字符串。
It can still be easily retrieved. It is the only img
inside the anchor named poster
.
它仍然可以轻松检索。它是名为poster的锚中唯一的img。
So, if you are reading the source, simply search for <a name="poster"
and it will be the text following the first src="
from there.
However, you will need to keep the screen scraping code updated because that will probably change.
但是,您需要更新屏幕抓取代码,因为这可能会更改。
You should also be aware that the images are copyrighted, so be careful to only use the image under a good "fair use" rationale.
您还应该知道图像是受版权保护的,因此请务必仅在良好的“合理使用”原理下使用图像。
#4
5
If a thumb is enough, you can use the Facebook Graph API: http://graph.facebook.com/?ids=http://www.imdb.com/title/tt0438097/
如果拇指足够,您可以使用Facebook Graph API:http://graph.facebook.com/ ?ids = http://www.imdb.com/title/tt0438097/
Gets you a thumbnail: http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg
获取缩略图:http://profile.ak.fbcdn.net/hprofile-ak-ash2/50289_117058658320339_650214_s.jpg
#5
5
I know that it is way too late, but in my project I used this:-
我知道这太晚了,但在我的项目中我使用了这个: -
- Use omdbapi, Lets take example of Inception, use www.omdbapi.com/?t=inception it will return a json object.
- In that json object get the "Poster" object, it contains the poster for the image.
使用omdbapi,让我们以Inception为例,使用www.omdbapi.com/?t=inception它将返回一个json对象。
在json对象中获取“Poster”对象,它包含图像的海报。
#6
3
omdbapi works, but I found out you cannot really use these images (because of screen scraping and they are blocked anyway if you use them in an img tag)
omdbapi有效,但我发现你不能真正使用这些图像(因为屏幕抓取,如果你在img标签中使用它们,它们会被阻止)
The best solution is to use tmdb.org :
最好的解决方案是使用tmdb.org:
1 use your imdbid in this api url:
1在这个api url中使用你的imdbid:
https://api.themoviedb.org/3/find/tt0111161?api_key=___YOURAPIKEY___&external_source=imdb_id
2 Retrieve the json response and select the poster_path
attribute:
2检索json响应并选择poster_path属性:
"poster_path":"/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg"
3 Prepend this path with "http://image.tmdb.org/t/p/original"
, and you will have the poster URL that you can use in an img tag :-)
3在此路径前加上“http://image.tmdb.org/t/p/original”,您将获得可在img标签中使用的海报网址:-)
4 You can even change sizes like this:
4您甚至可以更改这样的大小:
http://image.tmdb.org/t/p/original/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
http://image.tmdb.org/t/p/w150/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg
#7
2
You can use imdb-cli
tool to download movie's poster, e.g.
您可以使用imdb-cli工具下载电影的海报,例如
omdbtool -t "Ice Age: The Meltdown" | wget `sed -n '/^poster/{n;p;}'`
#8
1
Be aware tough, that the terms of service explicitly forbid screenscraping. You can download the IMDB database as a set of text files, but as I understand it, the IMDB movie ID is nowhere to be found in these text files.
请注意严格,服务条款明确禁止屏幕抓取。您可以将IMDB数据库下载为一组文本文件,但据我了解,这些文本文件中找不到IMDB电影ID。
#9
1
You can use Trakt API, you have to make a search request with the imdb ID, and the Json result given by Trakt API contains links for two images of that movie (poster and fan art) http://trakt.tv/api-docs/search-movies
您可以使用Trakt API,您必须使用imdb ID发出搜索请求,并且Trakt API提供的Json结果包含该电影的两个图像的链接(海报和粉丝艺术)http://trakt.tv/api-文档/搜索电影
#10
1
I've done something similar using phantomjs and wget. This bit of phantomjs accepts a search query and returns the first result's movie poster url. You could easily change it to your needs.
我使用phantomjs和wget做了类似的事情。这个phantomjs接受搜索查询并返回第一个结果的电影海报网址。您可以轻松地将其更改为您的需求。
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: moviePoster.js <movie name>');
phantom.exit();
}
var formattedTitle = encodeURIComponent(system.args[1]).replace(/%20/g, "+");
var page = require('webpage').create();
page.open('http://m.imdb.com/find?q=' + formattedTitle, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $(".title").first().find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return 'http://www.imdb.com' + $("#img_primary").find('a').attr('href');
});
page.close();
page = require('webpage').create();
page.open(url, function() {
var url = page.evaluate(function() {
return $(".photo").first().find('img').attr('src');
});
console.log(url);
page.close();
phantom.exit();
});
});
});
I download the image using wget for many movies in a directory using this bash script. The mp4 files have names that the IMDB likes, and that's why the first search result is nearly guaranteed to be correct. Names like "Love Exposure (2008).mp4".
我使用wget为使用此bash脚本的目录中的许多电影下载图像。 mp4文件具有IMDB喜欢的名称,这就是为什么第一个搜索结果几乎保证是正确的。名字如“Love Exposure(2008).mp4”。
for file in *.mp4; do
title="${file%.mp4}"
if [ ! -f "${title}.jpg" ]
then
wget `phantomjs moviePoster.js "$title"` -O "${title}.jpg"
fi
done
Then minidlna uses the movie poster when it builds the thumbnail database, because it has the same name as the video file.
然后minidlna在构建缩略图数据库时使用电影海报,因为它与视频文件具有相同的名称。
#11
1
$Movies = Get-ChildItem -path "Z:\MOVIES\COMEDY" | Where-Object {$_.Extension -eq ".avi" -or $_.Extension -eq ".mp4" -or $_.Extension -eq ".mkv" -or $_.Extension -eq<br> <br>".flv" -or $_.Extension -eq ".xvid" -or $_.Extension -eq ".divx"} | Select-Object Name, FullName | Sort Name <br>
#Grab all the extension types and filter the ones I ONLY want <br>
<br>
$COMEDY = ForEach($Movie in $Movies) <br>
{<br>
$Title = $($Movie.Name)<br>
#Remove the file extension<br>
$Title = $Title.split('.')[0] <br>
<br>
#Changing the case to all lower <br>
$Title = $Title.ToLower()<br>
<br>
#Replace a space w/ %20 for the search structure<br>
$searchTitle = $Title.Replace(' ','%20') <br>
<br>
#Fetching search results<br>
$moviesearch = Invoke-WebRequest "http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"<br>
<br>
#Moving html elements into variable<br>
$titleclassarray = $moviesearch.AllElements | where Class -eq 'title' | select -First 1<br>
<br>
#Checking if result contains movies<br>
try<br><br>
{
$titleclass = $titleclassarray[0]<br>
}<br>
catch<br>
{<br>
Write-Warning "No movie found matching that title http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"<br>
} <br>
<br>
#Parcing HTML for movie link<br>
$regex = "<\s*a\s*[^>]*?href\s*=\s*[`"']*([^`"'>]+)[^>]*?>"<br>
$linksFound = [Regex]::Matches($titleclass.innerHTML, $regex, "IgnoreCase")<br>
<br><br>
#Fetching the first result from <br>
$titlelink = New-Object System.Collections.ArrayList<br>
foreach($link in $linksFound)<br>
{<br>
$trimmedlink = $link.Groups[1].Value.Trim()<br>
if ($trimmedlink.Contains('/title/'))<br>
{<br>
[void] $titlelink.Add($trimmedlink)<br>
}<br>
}<br>
#Fetching movie page<br>
$movieURL = "http://www.imdb.com$($titlelink[0])"<br>
<br>
#Grabbing the URL for the Movie Poster<br>
$MoviePoster = ((Invoke-WebRequest –Uri $movieURL).Images | Where-Object {$_.title -like "$Title Poster"} | Where src -like "http:*").src <br>
<br>
$MyVariable = "<a href=" + '"' + $($Movie.FullName) + '"' + " " + "title='$Title'" + ">"<br>
$ImgLocation = "<img src=" + '"' + "$MoviePoster" + '"' + "width=" + '"' + "225" + '"' + "height=" + '"' + "275" + '"' + "border=" + '"' + "0" + '"' + "alt=" +<br> '"' + $Title + '"' + "></a>" + " " + " " + " "+ " " + " " + " "+ " " + " " + " "<br>
<br>
Write-Output $MyVariable, $ImgLocation<br>
<br>
}$COMEDY | Out-File z:\db\COMEDY.htm <br>
<br>
$after = Get-Content z:\db\COMEDY.htm <br>
<br>
#adding a back button to the Index <br>
$before = Get-Content z:\db\before.txt<br>
<br>
#adding the back button prior to the poster images content<br>
Set-Content z:\db\COMEDY.htm –value $before, $after<br>
#12
0
Those poster images don't appear to have any correlation to the title page, so you'll have to retrieve the title page first, and then retrieve the img element for the page. The good news is that the img tag is wrapped in an a tag with name="poster". You didn't say what kind of tools you are using, but this basically a screen scraping operation.
这些海报图像似乎与标题页没有任何关联,因此您必须先检索标题页,然后检索页面的img元素。好消息是img标签包含在一个名为=“poster”的标签中。你没有说你正在使用什么样的工具,但这基本上是一个屏幕抓取操作。
#13
0
Here is my program to generate human readable html summary page for movie companies found on imdb page. Change the initial url to your liking and it generates a html file where you can see title, summary, score and thumbnail.
这是我的程序,为imdb页面上的电影公司生成人类可读的html摘要页面。根据您的喜好更改初始网址,它会生成一个html文件,您可以在其中查看标题,摘要,分数和缩略图。
npm install -g phantomjs
Here is the script, save it to imdb.js
这是脚本,将其保存到imdb.js
var system = require('system');
var page = require('webpage').create();
page.open('http://www.imdb.com/company/co0026841/?ref_=fn_al_co_1', function() {
console.log('Fetching movies list');
var movies = page.evaluate(function() {
var list = $('ol li');
var json = []
$.each(list, function(index, listItem) {
var link = $(listItem).find('a');
json.push({link: 'http://www.imdb.com' + link.attr('href')});
});
return json;
});
page.close();
console.log('Found ' + movies.length + ' movies');
fetchMovies(movies, 0);
});
function fetchMovies(movies, index) {
if (index == movies.length) {
console.log('Done');
console.log('Generating HTML');
genHtml(movies);
phantom.exit();
return;
}
var movie = movies[index];
console.log('Requesting data for '+ movie.link);
var page = require('webpage').create();
page.open(movie.link, function() {
console.log('Fetching data');
var data = page.evaluate(function() {
var title = $('.title_wrapper h1').text().trim();
var summary = $('.summary_text').text().trim();
var rating = $('.ratingValue strong').attr('title');
var thumb = $('.poster img').attr('src');
if (title == undefined || thumb == undefined) {
return null;
}
return { title: title, summary: summary, rating: rating, thumb: thumb };
});
if (data != null) {
movie.title = data.title;
movie.summary = data.summary;
movie.rating = data.rating;
movie.thumb = data.thumb;
console.log(movie.title)
console.log('Request complete');
} else {
movies.slice(index, 1);
index -= 1;
console.log('No data found');
}
page.close();
fetchMovies(movies, index + 1);
});
}
function genHtml(movies) {
var fs = require('fs');
var path = 'movies.html';
var content = Array();
movies.forEach(function(movie) {
var section = '';
section += '<div>';
section += '<h3>'+movie.title+'</h3>';
section += '<p>'+movie.summary+'</p>';
section += '<p>'+movie.rating+'</p>';
section += '<img src="'+movie.thumb+'">';
section += '</div>';
content.push(section);
});
var html = '<html>'+content.join('\n')+'</html>';
fs.write(path, html, 'w');
}
And run it like so
然后像这样运行它
phantomjs imdb.js
#14
0
$Title = $($Movie.Name)
$searchTitle = $Title.Replace(' ','%20')
$moviesearch = Invoke-WebRequest "http://www.imdb.com/search/title?title=$searchTitle&title_type=feature"
$titleclassarray = $moviesearch.AllElements | where Class -eq 'loadlate' | select -First 1
$MoviePoster = $titleclassarray.loadlate
#15
-2
Now a days, all modern browser have "Inspect" section:
现在有一天,所有现代浏览器都有“Inspect”部分:
100% Correct for Google Chrome only:
仅适用于Google Chrome的100%正确:
- Take your cursor on image.
- Right click on it, select "Inspect Element".
- In the window appear, under Elements tab you will find the highlighted text as
- Just click on it.
- In the Resource tab, right click on image.
- Select "Copy image URL" option.
将光标放在图像上。
右键单击它,选择“Inspect Element”。
在窗口中,在“元素”选项卡下,您将找到突出显示的文本
只需点击它。
在“资源”选项卡中,右键单击图像。
选择“复制图像URL”选项。
Try to paste it any where as URL in any browser, you will only get the image.
尝试将其粘贴到任何浏览器中作为URL的位置,您将只获取图像。