chessgame.com's database for download?

Sort:
Boheme

Do any of you guys know if there's a way to download chessgame.com's database as a .pgn / .txt format?

Thanks.

msjenned
explore this opening
find similar games more games of Finnegan
 sac: 13.Rxe6+ PGN: download | view Help: general | java-troubleshooting

TIP: At the top of the page we display the common English name for the opening, followed by the ECO code (e.g. "C78"). The ECO codes are links that take you to opening pages.

PGN Viewer:  ChessTutor Chess Viewer Deluxe (Default) Chess Viewer Deluxe II (Beta) MistyBeach MyChess None (text only) pgn4web (Javascript) Sjkbase    What is this?
For help with the default chess viewer, please see the Chess Viewer Deluxe Quickstart Guide.

 

Under the game board you will see this one. Look at PGN. Have two options. View is text format. Non-member can download one game at one time.

Boheme

@msjenned: I'm actually more interested in getting lines of moves, by order of their popularity (as they are displayed on chessgame.com), not PGNs of individual games.

Thanks for the help, though. :)

Boheme

Lol, I think I found a solution myself:

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.util.ArrayList;

import java.util.List;

import java.util.regex.Pattern;

import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

import static org.hamcrest.CoreMatchers.*;

import org.openqa.selenium.*;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import org.openqa.selenium.support.ui.Select;

 

public class Test {

private static HtmlUnitDriver driver;

 

public static void main(String[] args) {

driver = new HtmlUnitDriver();

driver.get("http://www.chessgames.com/perl/explorer");

getMoves("http://www.chessgames.com/perl/explorer", new ArrayList<String>(), 0);

}

 

private static void getMoves(String back, List<String> prevmoves, int depth) {

List<WebElement> elementList = driver.findElements(By.xpath("//a"));

List<String> element_urls = new ArrayList<String>();

List<String> element_texts = new ArrayList<String>();

 

for (WebElement element : elementList) {

element_urls.add(element.getAttribute("href"));

element_texts.add(element.getText());

}

 

if (element_texts.get(1).equals("learn more")

|| !driver.getTitle().equals("Chess Opening Explorer")) {

printMoves(prevmoves);

return;

}

 

for (int i = 1 + depth; i < element_urls.size()

&& !element_texts.get(i).isEmpty(); i++) {

if (element_texts.get(i).equals("search database for this position"))

continue;

//System.out.println(element_texts.get(i));

prevmoves.add(element_texts.get(i));

String url = driver.getCurrentUrl();

driver.get(element_urls.get(i));

getMoves(url, prevmoves, depth + 1);

prevmoves.remove(prevmoves.size() - 1);

}

 

driver.get(back);

}

 

private static void printMoves(List<String> moves) {

String line = "";

for (String s : moves)

line += s + " ";

try {

BufferedWriter out = new BufferedWriter(new FileWriter("opening.txt", true));

out.write(line);

out.newLine();

out.close();

} catch (Exception e) {

e.printStackTrace();

}

}

}