Skip to content

Commit

Permalink
Implementation changed to adjust to new DBLP URL scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
cr-marcstevens committed Sep 18, 2020
1 parent 1735394 commit afca68c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ([2.68])
# Important: DBLPBIBTEX version needs to match with: ./version src/core.hpp
AC_INIT([dblpbibtex], [2.1], [[email protected]],[dblpbibtex],[https://github.com/cr-marcstevens/dblpbibtex])
AC_INIT([dblpbibtex], [2.3], [[email protected]],[dblpbibtex],[https://github.com/cr-marcstevens/dblpbibtex])
AC_CONFIG_SRCDIR([README.md])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_AUX_DIR([build-aux])
Expand Down
3 changes: 2 additions & 1 deletion src/bib_get.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace sa = string_algo;
/*** download citations ***/
bool download_dblp_citation(const std::string& key, bool prepend = true)
{
auto hdr_html = url_get("https://dblp.org/rec/bib" + std::to_string(params.dblpformat) + "/" + key.substr(5));
std::string url = "https://dblp.org/rec/" + key.substr(5) + ".bib?param=" + std::to_string(params.dblpformat);
auto hdr_html = url_get(url);
auto& html = hdr_html.second;
if (html.empty())
return false;
Expand Down
20 changes: 12 additions & 8 deletions src/bib_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,24 @@ bool search_citation_dblp(const std::string& citkey)
std::cout << "Search phrase too short <5 chars: '" << searchphrase << "'" << std::endl;
return false;
}
auto p_header_body = url_get("https://dblp.org/search/?q=" + searchphrase);
auto p_header_body = url_get("https://dblp.org/search?q=" + searchphrase);
auto& html = p_header_body.second;

html.erase(html.begin(), sa::ifind(html,"<body"));
std::set<std::string> cits2;
while (html.find("/rec/bibtex/") != std::string::npos)
while (html.find("/rec/") != std::string::npos)
{
std::string cit = html.substr(html.find("/rec/bibtex/"));
std::string cit = html.substr(html.find("/rec/"));
cit.erase(sa::to_lower_copy(cit).find_first_not_of("abcdefghijklmnopqrstuvwxyz0123456789:/.+-$&@=!?"));
cit.erase(0, std::string("/rec/bibtex/").length());
cit = "DBLP:" + cit;
cits2.insert(cit);
html.erase(0, html.find("/rec/bibtex/")+1);
std::cout << "Found citations: " << cit << std::endl;
cit.erase(0, std::string("/rec/").length());
if (cit.substr(cit.size()-5) == ".html")
{
cit.resize(cit.size()-5);
cit = "DBLP:" + cit;
cits2.insert(cit);
std::cout << "Found citations: " << cit << std::endl;
}
html.erase(0, html.find("/rec/")+1);
}
std::vector<std::string> cits(cits2.begin(), cits2.end());
if (cits.size() == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

//#define USE_CURL_FORM // use for old versions of curl that doesn't have curl_mime yet

#define VERSION "2.2"
#define VERSION "2.3"

#include <contrib/string_algo.hpp>
namespace sa = string_algo;
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION:2.2
VERSION:2.3

0 comments on commit afca68c

Please sign in to comment.