這是我的代碼:package mainimport (? ? "fmt"? ? "log"? ? "github.com/gocolly/colly")func main() {? ? c := colly.NewCollector(? ? ? ? colly.IgnoreRobotsTxt(),? ? ? ? colly.Async(false),? ? )? ? c.OnHTML("html", func(e *colly.HTMLElement) {? ? ? ? fmt.Println(e.Text)? ? })? ? c.OnError(func(_ *colly.Response, err error) {? ? ? ? log.Println("Something went wrong:", err)? ? })? ? c.Visit("https://www56.muenchen.de/termin/index.php?loc=BB")? ? c.OnScraped(func(r *colly.Response) {? ? ? ? fmt.Println("Finished")? ? })}問題是訪問網(wǎng)站后它會加載一些內(nèi)容。我不確定如何告訴 colly“等待”直到發(fā)生這種情況,然后查看結(jié)果。期待一些想法。去網(wǎng)絡(luò)抓取
1 回答

慕桂英3389331
TA貢獻2036條經(jīng)驗 獲得超8個贊
它不能,因為 colly 必須在客戶端執(zhí)行該操作,但 colly不執(zhí)行 JavaScript?- 因此沒有 Ajax。
要模擬瀏覽器,您可以使用 selenium 或 phantomjs。
- 1 回答
- 0 關(guān)注
- 111 瀏覽
添加回答
舉報
0/150
提交
取消