@@ -336,7 +336,7 @@ func (self ProjectLogic) ParseProjectList(pUrl string) error {
336
336
return err
337
337
}
338
338
339
- const OsChinaDomain = "http ://www.oschina.net"
339
+ const OsChinaDomain = "https ://www.oschina.net"
340
340
341
341
// ProjectLogoPrefix 开源项目 logo 前缀
342
342
const ProjectLogoPrefix = "plogo"
@@ -360,8 +360,8 @@ func (ProjectLogic) ParseOneProject(projectUrl string) error {
360
360
}
361
361
362
362
// 标题
363
- category := strings .TrimSpace (doc .Find ("#v -header header .box-aw h1 " ).Text ())
364
- name := strings .TrimSpace (doc .Find ("#v -header header .box-aw h1 span " ).Text ())
363
+ category := strings .TrimSpace (doc .Find (".detail -header h1 .project-title " ).Text ())
364
+ name := strings .TrimSpace (doc .Find (".detail -header h1 .project-name " ).Text ())
365
365
if category == "" && name == "" {
366
366
return errors .New ("projectUrl:" + projectUrl + " category and name are empty" )
367
367
}
@@ -383,8 +383,8 @@ func (ProjectLogic) ParseOneProject(projectUrl string) error {
383
383
return nil
384
384
}
385
385
386
- logoSelection := doc .Find ("#v -header header .logo img" )
387
- if logoSelection .AttrOr ("title " , "" ) != "" {
386
+ logoSelection := doc .Find (".detail -header .logo-wrap img" )
387
+ if logoSelection .AttrOr ("alt " , "" ) != "" {
388
388
project .Logo = logoSelection .AttrOr ("src" , "" )
389
389
390
390
if ! strings .HasPrefix (project .Logo , "http" ) {
@@ -400,19 +400,19 @@ func (ProjectLogic) ParseOneProject(projectUrl string) error {
400
400
}
401
401
402
402
// 获取项目相关链接
403
- doc .Find ("#v-details .urls a" ).Each (func (i int , aSelection * goquery.Selection ) {
404
- uri := util . FetchRealUrl ( OsChinaDomain + aSelection .AttrOr ("href" , "" ) )
405
- switch aSelection .Find ( "span" ). Text () {
403
+ doc .Find (".related-links a" ).Each (func (i int , aSelection * goquery.Selection ) {
404
+ uri := aSelection .AttrOr ("href" , "" )
405
+ switch aSelection .Text () {
406
406
case "软件首页" :
407
407
project .Home = uri
408
408
case "软件文档" :
409
409
project .Doc = uri
410
- case "软件下载 " :
410
+ case "官方下载 " :
411
411
project .Download = uri
412
412
}
413
413
})
414
414
415
- doc .Find ("#v-basic . list .box" ).Each (func (i int , liSelection * goquery.Selection ) {
415
+ doc .Find (".info- list .box .info-item " ).Each (func (i int , liSelection * goquery.Selection ) {
416
416
aSelection := liSelection .Find ("span" )
417
417
txt := strings .TrimSpace (aSelection .Text ())
418
418
if i == 0 {
@@ -431,8 +431,13 @@ func (ProjectLogic) ParseOneProject(projectUrl string) error {
431
431
project .Name = name
432
432
project .Category = strings .TrimSpace (category )
433
433
project .Uri = uri
434
- project .Repo = strings .TrimSpace (doc .Find ("#v-details .github-widget" ).AttrOr ("data-repo" , "" ))
435
- project .Src = "https://github.com/" + project .Repo
434
+ project .Src = project .Download
435
+
436
+ if strings .HasPrefix (project .Src , "https://github.com/" ) {
437
+ project .Repo = project .Src [len ("https://github.com/" ):]
438
+ } else {
439
+ project .Repo = project .Src [len ("https://gitee.com/" ):]
440
+ }
436
441
437
442
pos := strings .Index (project .Repo , "/" )
438
443
if pos > - 1 {
@@ -447,7 +452,10 @@ func (ProjectLogic) ParseOneProject(projectUrl string) error {
447
452
}
448
453
449
454
desc := ""
450
- doc .Find ("#v-details .detail" ).Find ("p" ).Each (func (i int , domSelection * goquery.Selection ) {
455
+ doc .Find (".project-body" ).Children ().Each (func (i int , domSelection * goquery.Selection ) {
456
+ if domSelection .HasClass ("ad-wrap" ) {
457
+ return
458
+ }
451
459
doc .FindSelection (domSelection ).WrapHtml (`<div id="tmp` + strconv .Itoa (i ) + `"></div>` )
452
460
domHtml , _ := doc .Find ("#tmp" + strconv .Itoa (i )).Html ()
453
461
if domSelection .Is ("pre" ) {
0 commit comments