Getting data from a site

Page 1 of 1

5 Replies - 315 Views - Last Post: 07 September 2011 - 12:30 PM Rate Topic: -----

#1 KFredje  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 131
  • Joined: 06-September 11

Getting data from a site

Posted 07 September 2011 - 11:30 AM

Hi,

I'm working on a new project to get the movie name and poster to my form in label1 and 2 if i press on button1. I'm really confused about this how I should do this. Should I rather do it with a regex or with a HtmlElementCollection?

This is a part of the code on the website:
<div class="poster"> 
  <a href="http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX320.jpg" width="" height="">  <img src="http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX81.jpg" width="" height=""></a> 
</div> 
 
<div class="mainInfo"> 

<h1>Avatar (2009)</h1> 
<p>Enter the World</p> 
 
<span class="trailer button-1 primary" data-link-text="Watch trailer" data-trailer-id="vi531039513"> 
</span> 
 
 
 
 
</div> 


KFredje

Is This A Good Question/Topic? 0
  • +

Replies To: Getting data from a site

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4462
  • View blog
  • Posts: 7,776
  • Joined: 08-June 10

Re: Getting data from a site

Posted 07 September 2011 - 11:37 AM

Well, what have you done so far?

First, you simply can't get a picture into label by any means.

Other than that, the answers to your questions depend on how you're getting the web data in the first place.
Was This Post Helpful? 0
  • +
  • -

#3 KFredje  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 131
  • Joined: 06-September 11

Re: Getting data from a site

Posted 07 September 2011 - 11:45 AM

Well, I got some resources from some code I found on the internet. But it doesn't seem to work.
This is for the movie name:
HtmlElementCollection itemsinTable = webBrowser1.document.GetElementsByTagName("div");
                    foreach (HtmlElement element in itemsinTable)
                    {
                        if (element.Parent.GetAttribute("className").Equals("mainInfo"))
                        {
                            label1.Text = element.InnerText;
                        }
                    }


For the image I have no clue. About the image in the label, I mean the url.
Was This Post Helpful? 0
  • +
  • -

#4 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4462
  • View blog
  • Posts: 7,776
  • Joined: 08-June 10

Re: Getting data from a site

Posted 07 September 2011 - 11:56 AM

I want to help, but you're going to have to help me help you. Statements like "it doesn't seem to be working" are non-answers. They don't contain enough useful information. What we're looking for is simple:

  • Code
  • Expected Results
  • Actual Results


Your post is skipping part 3. What does happen when you use that code?

Again, part of the problem here is scarcity of code. It looks like you're using a WebBrowser control. Do you really need to? Are you displaying this webpage to the user, or are you just trying to get the HTML in a way that your program can get it. If it's the second, use a WebClient object instead.

If you are showing it to the user, then it's probably for the best to keep using the WebBrowser. You're on the right track, you just have to work with the querying until you find what you're looking for. Use breakpoints and hover over collections to see what's in them, that'll help you find what you're looking for.
Was This Post Helpful? 0
  • +
  • -

#5 KFredje  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 131
  • Joined: 06-September 11

Re: Getting data from a site

Posted 07 September 2011 - 12:26 PM

So, I don't know much about getting data from the web to my application form, so I searched a little. I came up with this to get the full html page:
*** CODE REMOVED ***


So this code loads the full html page to my textBox1 to see if it works. So how do I get a certain data from it now? Just like I did with the webbrowser?
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Getting data from a site

Posted 07 September 2011 - 12:30 PM

Unless you have express, written permission to do so, you are in violation of IMDB's Terms of Service:

Quote

Robots and Screen Scraping: You may not use data mining, robots, screen scraping, or similar data gathering and extraction tools on this site, except with our express written consent as noted below.
...
Licensing IMDb Content; Consent to Use Robots and Crawlers: If you are interested in receiving our express written permission to use IMDb content for your non-personal (including commercial) use, please visit our Content Licensing section or contact our Licensing Department. We do allow the limited use of robots and crawlers, such as those from certain search engines, with our express written consent. If you are interested in receiving our express written permission to use robots or crawlers on our site, please contact our Licensing Department.


As we don't know whether you have that permission, we cannot assist you in this endeavor.

Topic closed.
Was This Post Helpful? 3
  • +
  • -

Page 1 of 1