🔒 Closed C# Web Scraping Need Help HtmlAgilityPack

Status
Not open for further replies.

1nn0c3ntv5

Fanatic
Paano ko po makukuha yung value ng src mula dun sa node.InnerHtml?

Ito yung actual output ko:

1615815275498.webp

Yung desired output ko ay dapat yung mga value lang ng src ang lalabas

[CODE lang="csharp" title="Code"] string link = "https://www.bing.com/images/search?q=makati%20city&qs=n&form=QBIR&sp=-1&ghc=1&pq=makati%20city&sc=8-11&cvid=8AD15CB714714537AF258130B0C01DB8&first=1&tsc=ImageBasicHover";
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load(link);
List<string> listResults = new List<string>();
int i = 0;
//get each listing

foreach (HtmlNode node in doc.DocumentNode.Descendants("div").Where(d =>
d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("img_cont hoff")))
{
// Console.WriteLine($"Item No: {i}");
Console.WriteLine($"Result {i}\n\n{node.InnerHtml}");

// string dataSrcValue = node.Attributes["data-src"].Value;

// Console.WriteLine(node.InnerText);
// Console.WriteLine(gg.GetAttributeValue("data-src", "nothing"));
// var linker = node.Descendants("img").First(x => x.Attributes["class"] != null && x.Attributes["class"].Value == "mimg");
//Console.WriteLine($"{hrefValue}");

i++;
}[/CODE]
 
may Alam Kang Java compiler na sa cp lng Marun need ko Kasi output Niya

Java:
interface Polygon {
  void getArea();

  // default method
  default void getSides() {
    System.out.println("I can get sides of a polygon.");
  }
}

// implements the interface
class Rectangle implements Polygon {
  public void getArea() {
    int length = 6;
    int breadth = 5;
    int area = length * breadth;
    System.out.println("The area of the rectangle is " + area);
  }

  // overrides the getSides()
  public void getSides() {
    System.out.println("I have 4 sides.");
  }
}

// implements the interface
class Square implements Polygon {
  public void getArea() {
    int length = 5;
    int area = length * length;
    System.out.println("The area of the square is " + area);
  }
}

class Main {
  public static void main(String[] args) {

    // create an object of Rectangle
    Rectangle r1 = new Rectangle();
    r1.getArea();
    r1.getSides();

    // create an object of Square
    Square s1 = new Square();
    s1.getArea();
    s1.getSides();
  }
}
 
may Alam Kang Java compiler na sa cp lng Marun need ko Kasi output Niya

Java:
interface Polygon {
  void getArea();

  // default method
  default void getSides() {
    System.out.println("I can get sides of a polygon.");
  }
}

// implements the interface
class Rectangle implements Polygon {
  public void getArea() {
    int length = 6;
    int breadth = 5;
    int area = length * breadth;
    System.out.println("The area of the rectangle is " + area);
  }

  // overrides the getSides()
  public void getSides() {
    System.out.println("I have 4 sides.");
  }
}

// implements the interface
class Square implements Polygon {
  public void getArea() {
    int length = 5;
    int area = length * length;
    System.out.println("The area of the square is " + area);
  }
}

class Main {
  public static void main(String[] args) {

    // create an object of Rectangle
    Rectangle r1 = new Rectangle();
    r1.getArea();
    r1.getSides();

    // create an object of Square
    Square s1 = new Square();
    s1.getArea();
    s1.getSides();
  }
}
D ko alam sensya, hindi ako nag j-java.
 
O nga no, ngayon ko lang nabasa, tingin ko mas maganda ganyan.

Yung ginawa kong solution ay pinarse ko yung bawat index tas ginawa kong empty string hanggang src na lang matira haha
 
Status
Not open for further replies.

About this Thread

  • 8
    Replies
  • 443
    Views
  • 4
    Participants
Last reply from:
zackmark29

Trending Topics

Online now

Members online
1,210
Guests online
1,961
Total visitors
3,171

Forum statistics

Threads
2,294,559
Posts
29,091,818
Members
1,207,382
Latest member
travis_09
Back
Top