在Lubuntu上,我可以先安装Tor然后再连接到其袜子代理来使用tor,但是在带alpine的docker上,似乎并不那么容易。由于我按原样离开了/ etc / tor / torrc,所以它仅由注释掉的行组成。因此,对于高山用户,我只使用了torrc.sample仅包含注释掉的行的文件。
这是我的Dockerfile:
FROM alpine:latest
RUN apk update && apk upgrade && apk add tor curl && rm /var/cache/apk/* && cp /etc/tor/torrc.sample /etc/tor/torrc
EXPOSE 9050
USER tor
CMD /usr/bin/tor -f /etc/tor/torrc
Run Code Online (Sandbox Code Playgroud)
然后我就跑了:
$ sudo docker build -t tor .
$ sudo docker run --name tor -p 9050:9050 tor
$ curl -x socks5://localhost:9050 -k https://23.128.64.134/ip
curl: (7) Unable to receive initial SOCKS5 response.
$ curl -x socks4://localhost:9050 -k https://23.128.64.134/ip
curl: (7) Failed to …Run Code Online (Sandbox Code Playgroud) 我正在使用Html2Text将HTML代码转换为文本.效果很好,但我在互联网上找不到很多例子或文档.
我正在以这种方式读取用户名:
text_to_gain = hxs.xpath('//div[contains(@id,"yq-question-detail-profile-img")]/a/img/@alt').extract()
if text_to_gain:
h = html2text.HTML2Text()
h.ignore_links = True
item['author'] = h.handle(text_to_gain[0])
else:
item['author'] = "anonymous"
Run Code Online (Sandbox Code Playgroud)
但我的输出是这样的:
u'Duncan\n\n'
Run Code Online (Sandbox Code Playgroud)
当我读取长文本或消息时,它是有用的,但是对于单个字符串或某个字符串,我只想保留名称.
'Duncan'
Run Code Online (Sandbox Code Playgroud)