Atypon Journals

Hi guys!
I need to extend the current atypon translator so that it will also collect author affiliation when it scrape the site.
But I'm having big problem with understanding how to extend it.
I have tried to add var that I call affiliation, and used the function
doc.getElementsByClassName('listGroup') and told it that it can find this information in the <li class="listGroup"> But this doesn't work, can someone please tell me how I can do this?
  • edited October 23, 2015
    I'd have to see where the affiliation is actually stored (this isn't a universal feature of Atypon) in the metadata, but generally something like
    var affiliation = [];
    var affiliations = doc.getElementsByClassName('listGroup')
    for (i=0; i<affiliations.length; i++){
    affiliation.push(affiliations[i].textContent)
    }

    would give you the text content of every listGroup node in an affiliation array.
  • So if you look on my pastebin here:

    http://pastebin.com/4FpbcL6N

    Could that just work for me?
  • it needs to be var affiliations (with s) in line 194, but beyond that: this will save the array (again, haven't tested--this was for the general idea), but it won't do anything with it and you won't have access to it once the translator completes.
    Zotero doesn't have a field for storing author affiliations and you can't create custom fields, so you need to think about what you want to do with this in the existing Zotero data model.
  • Hmm okay.

    The thing I wanna do is the get the author affiliation and also be able to extract it from this scan function I have made in my java-program:

    http://pastebin.com/7HUhjFsW

    As you can see there I'm already extracting the abstract from the JSON-array that I get back.
    Is there some way I can store the affiliation in some other field in Zotero? I just really need to scrape it and add it to my database.
  • you could convert the array into a string (semicolon separated or so) and then store it in item.extra if you want to. Since that's also used otherwise by translators, you'd probably want to include a unique marker at the beginning. (just so we're communicating right, though: these are hacks for personal use. We'd definitely not accept this into the general Atypon translator).
  • Ofc I understand that this is personal use only.
    How come there is no field for author affiliation btw?

    So if I get you right, something like this will make the affiliation come in the field item.extra instead?

    var affiliations = doc.getElementsByClassName('listGroup');

    item.extra = affiliation;

    or I'm wrong?
  • edited October 23, 2015
    more like (getElementsByClassName gets you a list of nodes, not a string. it's not something you can save to a Zotero field)

    var affiliations = doc.getElementsByClassName('listGroup');
    for (i=0; i<affiliations.length; i++){
    affiliation.push(affiliations[i].textContent)
    }
    item.extra = affiliation.join("; ");

    The details, again, depend on how the data is actually stored on the site. Possibly using ZU.xpathText(doc, xpath) will work better. And I've written all of the above without a syntax checker, so no promises on that front.
  • no affiliation because it's not cited and rarely requested otherwise.
  • Ah okay will try this and get back with the result :)

    Okay can understand that.
  • Okay, what can be wrong when I try this and I don't get any stream back from the server at all?
    The server is telling me "string => ReferenceError: affiliation is not defined".

    Here is my code again:

    http://pastebin.com/czikWzDM
  • you need to define an empty array before you can push to it:
    var affiliation = [];
  • Thx it's working now!
  • Adamsmish and Anderssinho,
    I would like get author affiliation to my work. I think to identify the groups around world that work in the same subject. I saw your javascript but I know nothing in programming. Nothing nothing. How can I run that? And where I can put DOI...
  • It's not my code, so you'll have to ask @anderssinho .
    I don't understand the question about DOIs?
  • hum ok, forget this question. I will ask to anderssinho. Thank you
Sign In or Register to comment.