Coder Social home page Coder Social logo

tiebaspider's People

Contributors

hjhee avatar inactive0v0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tiebaspider's Issues

不知道这是个什么BUG

我在.txt里记录了这四个链接,结果就打开tiebaspider之后就出现下面这样的error提示;不过文件倒是都生成了。(我不知道生成的有没有错误)
于是我把output文件夹清空了,这几个链接一个一个粘贴保存爬取,这次就没发现有下图这样的error提示。不知道什么情况,总之来这儿记录一下。
https://tieba.baidu.com/p/6686629174
https://tieba.baidu.com/p/6687216651
https://tieba.baidu.com/p/6687241276
https://tieba.baidu.com/p/6687266097

image

建议:文件开头附上帖子链接

如题,就是在那个html文件第一行附上帖子的原本链接,这样想回查帖子就方便很多了。
尤其是我每次把它导入印象笔记后要更新来源网址,如果能这样会方便很多。
image

非常感谢能有这么好的工具,太感谢了。

对于许多楼层为同一人所发的帖子生成html的排版有些混乱

问题出现在一个楼主连续占用了很多楼层、且图片极少的帖子之中。此前没有抓取过有这种特征的帖子,所以没有发现这个问题。

生成的html文件将许多楼层的正文被合并到了一起,原本该楼层的日期、层主ID、楼层号等基本格式被省略掉了。而且有的楼层的开头(比如图1里有张插图后面的“预计”2字,还有以序号“1、”“2、”开头的文字)被排到了上一层正文的末尾。这些使得页面看起来就比较凌乱。

详细可见部分截图以及原始网页的截图。原帖地址为这个

捕获-1
捕获-3
捕获-2

失效的gif链接会让任务卡住无法继续

感谢制作,好贴存在本地以免被封没得看了,在存某一贴时会卡在缓存两个gif上面,链接已经失效,报错HTTP ERROR 503,进而无法继续进行,可以考虑设置多少次失败就跳过,或者其他更妙的解决办法,感谢

原贴:
https://tieba.baidu.com/p/2103445499

exe报错:
2023-02-06 09:47:40 [Fetch] error fetching http://www.klss.cn/upimg/allimg/110221/105G34Z0-2.gif, pause for 3s: Get "http://www.klss.cn/upimg/allimg/110221/105G34Z0-2.gif": dial tcp: lookup www.klss.cn: no such host
2023-02-06 09:47:40 [Fetch] error fetching http://www.klss.cn/upimg/allimg/110221/105G34962-27.gif, pause for 3s: Get "http://www.klss.cn/upimg/allimg/110221/105G34962-27.gif": dial tcp: lookup www.klss.cn: no such host

建议:将缩略图图片链接替换为原图

现在,这个工具爬取到的图片链接都是缩略图链接。爬取得到的网页,打开之后显示的自然也是缩略图链接。
而且还无法自动查看大图,原帖子里点击缩略图是可以查看大图的。

我想,反正用这个工具的人都是用电脑和宽带,没人会在乎流量吧。所以不如直接把图片链接替换成原图。
我找了几个帖子里面的图片,发现图片链接的命名挺好改的:
缩略图链接(这些链接似乎要手动复制粘贴到输入网址的地方才能打开,当然,在爬取得到的html文件里都是能正常显示的):
https://imgsa.baidu.com/forum/w%3D580/sign=b13fff0d831001e94e3c1407880c7b06/917edd628535e5ddf5e2133b78c6a7efcc1b6240.jpg
https://imgsa.baidu.com/forum/w%3D580/sign=93928a239e529822053339cbe7cb7b3b/b5dc04338744ebf8cffdd2dbd7f9d72a6259a787.jpg
https://imgsa.baidu.com/forum/w%3D580/sign=ffabff668e0a19d8cb03840d03fb82c9/aa482ec79f3df8dce2142946c311728b46102847.jpg
https://imgsa.baidu.com/forum/w%3D580/sign=f74848d9e724b899de3c79305e071d59/7a6b1dfa513d2697869e6a845bfbb2fb4216d826.jpg
大图链接:
https://imgsrc.baidu.com/forum/pic/item/917edd628535e5ddf5e2133b78c6a7efcc1b6240.jpg
https://imgsrc.baidu.com/forum/pic/item/b5dc04338744ebf8cffdd2dbd7f9d72a6259a787.jpg
https://imgsrc.baidu.com/forum/pic/item/aa482ec79f3df8dce2142946c311728b46102847.jpg
http://imgsrc.baidu.com/forum/pic/item/7a6b1dfa513d2697869e6a845bfbb2fb4216d826.jpg
我不懂程序,感觉只要在爬取完毕后进行全部替换:
https://imgsa.baidu.com/forum/.{1,45}
http://imgsrc.baidu.com/forum/pic/item
就能实现这个功能。

贴吧的表情的链接是这样的,不会被上面的替换影响到,所以应该不会有问题。
https://gsp0.baidu.com/5aAHeD3nKhI2p27j8IqW0jdnxx1xbK/tb/editor/images/client/image_emoticon13.png

当然这个也可以我自己手动做,下载下来之后用文本编辑器打开html全部替换就行了。
我是因为贴吧把以前的贴隐藏了才认识到必须得把重要帖子保存起来,然后搜了一圈就只发现了您这个最合适,能爬取一个帖子的所有内容(含所有楼中楼、图片),而且还能以html的形式保存下来!
所以对我来说,真正影响使用的是前面说的无法获得帖子最后一页的楼中楼,如果您看到这issue能不能说一下关于这点改起来是麻烦还是简单呢,如果不算麻烦的话希望能修改,现在我是日日盼夜夜盼😂
我不懂编程,所以如果掏钱能让您愿意把这点改进的话也好啊,我愿意赞助一些(50您看行不= =),谢谢了🙏

同样运行不了,望更新解决

这是当时的日志
`[root@localhost tiebaSpider]# go run main.go

# command-line-arguments

./main.go:72:19: undefined: fetchHTMLList

./main.go:73:22: undefined: parseHTML

./main.go:74:25: undefined: renderHTML

./main.go:87:16: select case must be receive, send or assign recv

./main.go:94:16: select case must be receive, send or assign recv

./main.go:101:16: select case must be receive, send or assign recv

./main.go:108:17: select case must be receive, send or assign recv
`

[bug] 楼层发布时间错误

检查 JSON 文件会发现一部分楼层的时间变成了 "Time": "来自Android客户端"

看代码好像 这里 是解析楼层时间的?我比较建议直接整段拿到手然后正则 \d{4}-\d\d-\d\d \d\d:\d\d 提取,不要搞选择器精确选择了,各种边缘情况比较多,很容易出 BUG

楼中楼用户名称错误

您好,首先感谢您开源的代码
由于我比较关注的是楼中楼内的回复关系,但是爬取出的楼中楼内名称是错误的,如下:
image
image
这种情况应该怎么办呢?感谢!

贴吧id显示错误

首先还是感谢您能发布这么好的东西。试了几个帖子。

1、如果贴吧id后面有带表情符号的话,会乱码。例如这个帖子,
https://tieba.baidu.com/p/6209031748?pn=3
77楼的ID是“你失散的野爹😂”,用这个软件保存的结果是“钃濋瓟铦庰煢”

2、在楼中楼里的“A回复B:……”中,B有链接。但是打开这个链接会显示错误。
感觉不如直接把这个链接删了。

图片本地化的一种解决方案

Hi,
我使用你的代码,成功保存了一批珍贵资料。感谢你所做的工作。
关于“收集网页出现的所有图片并保存至本地,把所有图片内嵌至html”,我的解决思路是这样的:
先使用tiebaImageGet将帖子图片下载到本地文件夹(名称为帖子PID),然后修改html文件中的image src. 这种方式下载的图片为贴吧缩略图,避免了浏览器同时加载原图导致内存占用过大的问题。

python代码如下:

def modify_src(folder_path, file_name):
    file_path = folder_path + '//' + file_name

    soup = BeautifulSoup(open(file_path, encoding = "utf-8"), "html.parser")
    url = [elm.get_text() for elm in soup.find_all("a", href=re.compile(r"^https://tieba.baidu.com/p/"))]
    
    # Some links are http
    if len(url) == 0:
        url_new = [elm.get_text() for elm in soup.find_all("a", href=re.compile(r"^http://tieba.baidu.com/p/"))]
        pid = url_new[0][-10:]
    else:
        # get pid
        pid = url[0][-10:]

    # modify image src
    # unmodified src: https://imgsa.baidu.com/forum/w%3D580/sign=4d3033fbbdde9c82a665f9875c8080d2/4417d558ccbf6c815f62fb2ab23eb13532fa4035.jpg
    # modified: ./img/6233150605/09d6a94bd11373f0a6c6bb5daa0f4bfbf9ed0488.jpg
    # pattern: ./img/pid/img_name
    # img_name: img["src"][-44:]
    # unmodified emoticon src :https://gsp0.baidu.com/5aAHeD3nKhI2p27j8IqW0jdnxx1xbK/tb/editor/images/client/image_emoticon72.png
    # modified: ../emoticon/image_emoticon72.png
    for img in soup.findAll('img',{"src":True}):
        if img["src"].endswith(".jpg"):
            modified = './img/' + pid + '/' + img['src'][-44:]
            img['src'] = modified
        if img['src'].endswith('.png'):
            splited = img['src'].split('/')
            emoticon_name = splited[-1]
            emoti_modified = '../tieba_emoticon/' + emoticon_name
            img['src'] = emoti_modified

    with open(file_path, "w", encoding = "utf-8") as file:
        file.write(str(soup))

所用到的emoticon文件:tieba_emoticon.zip

祝好,
Jingyi

[Parse] error: unable to parse page(title: 百度安全验证)

Hi,
感谢你分享这个出色的备份程序。
我在备份帖子时,遇到了这个报错信息:

[Parse] error: unable to parse page(title: 百度安全验证), possibly a network error, readding url to queue

我在浏览器中打开百度贴吧,完成了安全验证,然后重新执行程序。依然出现该报错信息。我尝试了退出百度账号/使用IP代理,无效。请问这个问题该如何解决?
环境:win10, go1.14.1, program runs in CMD.

运行不了是怎么回事

go run main.go
输出如下
.\main.go:72:19: undefined: fetchHTMLList
.\main.go:73:22: undefined: parseHTML
.\main.go:74:25: undefined: renderHTML
.\main.go:87:16: select case must be receive, send or assign recv
.\main.go:94:16: select case must be receive, send or assign recv
.\main.go:101:16: select case must be receive, send or assign recv
.\main.go:108:17: select case must be receive, send or assign recv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.