1

I am trying to retrieve the whole overview section for this url

What would be the elements i look for in the three different articles?

http://xbox360.gamespy.com/xbox-360/project-dark/

Is there anyway to create a default selector to retrieve the overview for this page also?

http://wii.gamespy.com/wii/ben-10-galactic-racing/

EDIT http://wwww.gamespy.com/pc/6-great-games

i would like to make a selector for the different tags. So if one a url is selected if it has the selector then it will load the data, if it doesnt it will try another selectory.

How could i go about doing this?

Is it possible to create different selectors looking for different tags for the different articles?

coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118

2 Answers2

1

Look for the div with id "overview-section", then select the p child.

aromero
  • 25,681
  • 6
  • 57
  • 79
1

This should get the overview text on all three webpages

// Get the overview div
Element overview = doc.select("div#object-overview").last();

// Get the paragraph element
Element paragraph = overview.select("p").last();
System.out.println(paragraph.text());

As for different selectors for different webpages, you could do something like a HashMap.

// Create new HashMap
HashMap<String, String> selectorMap = new HashMap<String, String>();

// Put the Key-Value pair in the Hashmap
selectorMap.put("http://wii.gamespy.com/wii/ben-10-galactic-racing/", "div#object-overview");

// Get the value by supplying the key (the webpage's url)
String selector = selectorMap.get("http://wii.gamespy.com/wii/ben-10-galactic-racing/");

Let me know if this is what you were looking for.

To get the Feature List:

// Get the overview div element
Element featureList = doc.select("div.callout-box").last();

Elements features = featureList.select("li");

ListIterator<Element> featList = features.listIterator();
while (featList.hasNext()) {
    System.out.println(featList.next().text() + "\n");

}

To get the Edition List:

// Get the div.columns element - this is the base of each edition
Elements editions = doc.select("div.columns");

ListIterator<Element> editionsList = editions.listIterator();
while (editionsList.hasNext()) {
    // Get that edition
    Element edition = editionsList.next();

    // Get the edition name element
    Element editionName = edition.select("h3").first();
    System.out.println(editionName.text());

    // Get the edition info element
    Element editionInfo = edition.select("p").last();
    System.out.println(editionInfo.text() + "\n");

}
Aaron Foltz
  • 138
  • 2
  • 9
  • The first part worked for the link http://xbox360.gamespy.com/xbox-360/project-dark/ The thing is i am retreiving this list http://www.gamespy.com/index/release.html of items and putting them into a list. When a item is clicked the url is retrieved and i would like to get the overriew section no matter what item it is. here is where the items are. Maybe it is a similar tag element i could use for all of the them? – coder_For_Life22 Aug 16 '11 at 15:03
  • That's odd. All of the games that I'm going to work and have `
    ` as the base element of each overview.
    – Aaron Foltz Aug 16 '11 at 15:14
  • Okay one second im going to try it out using any of the urls – coder_For_Life22 Aug 16 '11 at 15:20
  • That did it. one more thing.. if you notic on some of the items of the list, on their pages they have a feature list and editions list..How could i retreive this info also? – coder_For_Life22 Aug 16 '11 at 15:41
  • I know how i could retrieve it with a selector but what would be the tags? – coder_For_Life22 Aug 16 '11 at 15:41
  • Some of the items force close for some reason when the item is clicked. The rest work fine its only a few If you look in the list of games for instance the game Breathe of Fire for psp check it out..It force closes..Maybe something is up with the html thats different? – coder_For_Life22 Aug 16 '11 at 17:08
  • Some of the items force close for some reason when the item is clicked. The rest work fine its only a few If you look in the list of games for instance the game Breathe of Fire for psp check it out..It force closes..Maybe something is up with the html thats different? – coder_For_Life22 Aug 16 '11 at 19:20