ftr我已经在这两个框架中成功地编写了很多scraper,但是我很困惑。这是我试图搜集的数据的截图(您也可以转到get请求中的实际链接):
  
  
   
     
   
  
  
  
  
   我试图瞄准
   
    div.section_content
   
   以下内容:
  
  import requests
from bs4 import BeautifulSoup
html = requests.get("https://www.baseball-reference.com/boxes/ARI/ARI201803300.shtml").text
soup = BeautifulSoup(html)
soup.findAll("div", {"class": "section_content"})
  
   打印最后一行显示一些其他div,但不显示具有俯仰数据的div。
  
  
   但是,我可以在文本中看到它,因此它不是javascript触发的加载问题(短语“pitching”只出现在该表中):
  
  >>> "Pitching" in soup.text
True
  
   以下是Golang一次尝试的缩略版本:
  
  package main
import (
    "fmt"
    "github.com/gocolly/colly"
) 
func main() {
    c := colly.NewCollector(
            colly.AllowedDomains("www.baseball-reference.com"),
    )   
    c.OnHTML("div.table_wrapper", func(e *colly.HTMLElement) {
            fmt.Println(e.ChildText("div.section_content"))
    })  
    c.Visit("https://www.baseball-reference.com/boxes/ARI/ARI201803300.shtml")
  
   }
}