Go-pholcus Crawl Ijguc All periodicals

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.
 PackageSpider_lib//Basic PackageImport(//"Log"    "Github.com/puerkitobio/goquery"                        //dom parsing    "Github.com/henrylee2cn/pholcus/app/downloader/request" //Required."Github.com/henrylee2cn/pholcus/app/spider"           //Required    //"github.com/henrylee2cn/pholcus/logs"//Information output    // . "Github.com/henrylee2cn/pholcus/app/spider/common"//Selection    //NET package    //"net/http"//Set HTTP. Header    //"Net/url"    //Code pack    //"Encoding/xml"    //"Encoding/json"    //String processing package    "RegExp"    "StrConv"    //"strings"    //Other packages    //"FMT"    //"math"    //"Time")funcInit () {Ijguc. Register ()}varIJGUC = &spider{Name:"IJGUC Journal", Description:"IJGUC Journal",//pausetime:300,    //Keyin:keyin,    //Limit:limit,Enablecookie:false, Ruletree: &ruletree{Root:func(CTX *context) {ctx. Addqueue (&request. request{URL:"Http://www.inderscience.com/info/inarticletoc.php?jcode=ijguc&year=2016&vol=7&issue=1", Rule:"Journal list",})}, Trunk:Map[string]*rule{"Journal list": {parsefunc:func(CTX *context) {query: = CTX. GetDOM () forI: =1; I <=7; i++ {id: ="#eventbody"+ StrConv. Itoa (i) +"a"Query. Find (ID). each (func(jint, S *goquery. Selection) {ifURL, OK: = S.attr ("href"); OK {//log. Print (URL)CTx. Addqueue (&request. Request{url:url, Rule:"article List"})                            }                        })                    }                },            },"article List": {parsefunc:func(CTX *context) {query: = CTX. GetDOM ()//#journalcol1 Article Table tbody tr td:eq (1) table:eq (1) aQuery. Find ("#journalcol1 article table tbody tr TD"). each (func(Iint, TD *goquery. Selection) {ifi = =1{TD. Find ("Table"). each (func(jint, table *goquery. Selection) {ifj = =1{table. Find ("a"). each (func(kint, a *goquery. Selection) {ifK%2==0{ifURL, OK: = A.attr ("href"); OK {//log. Print (URL)CTx. Addqueue (&request. Request{url:url, Rule:"article page"})                                            }                                        }                })                                }                            })                        }                    }) },            },"article page": {//Note: There is no word Qi and whether the output data must be consistentItemfields: []string{"Title","Author","Addresses","Journal","Abstract","Keywords","DOI",}, Parsefunc:func(CTX *context) {query: = CTX. GetDOM ()//Get contentContent: = Query. Find ("#col1"). Text ()//Filter LabelRe, _: = Regexp.compile ("\\<[\\s\\s]+?\\>") content = Re. Replaceallstring (Content,"")//TitleRe, _ = Regexp.compile ("Title: (. *?) Author: ") Title: = Re. Findstringsubmatch (content)[1]//AuthorRe, _ = Regexp.compile ("Author: (. *?) Addresses: ") au: = re. Findstringsubmatch (content)varAuthorstring                    if Len(AU) >0{Author = au[1]                    }Else{Re, _ = Regexp.compile ("Author: (. *?) Address: ") Author = re. Findstringsubmatch (content)[1]                    }//Addresses & AddressRe, _ = Regexp.compile ("Addresses: (. *?) Journal: "Address: = Re. Findstringsubmatch (content)varAddressesstring                    if Len(address) >0{addresses = Address[1]                    }Else{Re, _ = Regexp.compile ("Address: (. *?) Journal: ") addresses = Re. Findstringsubmatch (content)[1]                    }//JournalRe, _ = Regexp.compile ("Journal: (. *?) Abstract: ") Journal: = Re. Findstringsubmatch (content)[1]//AbstractRe, _ = Regexp.compile ("Abstract: (. *?) Keywords: ") Abstract: = Re. Findstringsubmatch (content)[1]//KeywordsRe, _ = Regexp.compile ("Keywords: (. *?) DOI: ") Keywords: = Re. Findstringsubmatch (content)[1]//DOIRe, _ = Regexp.compile ("DOI:") Doiindex: = Re. Findstringsubmatchindex (content) rs: = []Rune(content) Left: = Doiindex[1] -8Right: = left + +DOI: =string(Rs[left:right])//Results deposited response relayCTx. Output (Map[int]Interface{}{0: Title,1: Author,2: Addresses,3: Journal,4: abstract,5: keywords,6: DOI,})},},},},}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.