<commit_before><?php

function getCURLOutput($url){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
  $output = curl_exec($ch);
  curl_close($ch);
  return $output;
}

function getDOMXPath($page){
  $dom = new DOMDocument;
  $page = mb_convert_encoding($page, 'HTML-ENTITIES', "UTF-8");
  @$dom->loadHTML($page);
  $xpath = new DOMXPath($dom);
  return $xpath;
}

function getTopics ($forumUrl) {
  $baseUrl = "http://www.jeuxvideo.com";
  $topics = array();
  $forumPage = getCURLOutput($forumUrl);
  $forumXpath = getDOMXPath($forumPage);
  $topicsName = $forumXpath->query('//*[@class="titre-topic"]/a/text()');
  $topicsNodes = $forumXpath->query('//*[@class="titre-topic"]/a');
  foreach($topicsNodes as $key => $node) {
    if($key > 4){ // first 4 topics are often pinned
      $topic = (object) array('name' => $topicsName->item($key)->nodeValue, 'url' => $baseUrl . $node->getAttribute("href"));
      $topics[] = $topic;
    }
  }
  return $topics;<commit_msg>Fix XPath selector for topic title and link<commit_after><?php

function getCURLOutput($url){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17');
  $output = curl_exec($ch);
  curl_close($ch);
  return $output;
}

function getDOMXPath($page){
  $dom = new DOMDocument;
  $page = mb_convert_encoding($page, 'HTML-ENTITIES', "UTF-8");
  @$dom->loadHTML($page);
  $xpath = new DOMXPath($dom);
  return $xpath;
}

function getTopics ($forumUrl) {
  $baseUrl = "http://www.jeuxvideo.com";
  $topics = array();
  $forumPage = getCURLOutput($forumUrl);
  $forumXpath = getDOMXPath($forumPage);
  $topicsName = $forumXpath->query('//*[@id="forum-main-col"]/div[3]/ul/li/span[1]/a/text()');
  $topicsNodes = $forumXpath->query('//*[@id="forum-main-col"]/div[3]/ul/li/span[1]/a');
  foreach($topicsNodes as $key => $node) {
    if($key > 4){ // first 4 topics are often pinned
      $topic = (object) array('name' => $topicsName->item($key)->nodeValue, 'url' => $baseUrl . $node->getAttribute("href"));
      $topics[] = $topic;
    }
  }
  return $topics;
{'fraction_non_alphanumeric': 0.19179986101459348, 'fraction_numerical': 0.0236275191104934, 'mean_word_length': 4.997916666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4384511', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1117, 'n_words': 200}