English 中文(简体)
• 寻找图书馆,编造相对/全色的图书馆。 [闭门]
原标题:Looking for library to concat relative / full urls. [closed]

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 8 years ago.

I m writing a scraper program. I collect all the links on a page. They might be relative paths. For example:

foo.html
/foo.html
../foo.html
../../foo.html

I can concat them to the url of the page (basepath) they are on, but that isn t completely straightforward. For example:

http://www.example.com/foo + /bar.html = http://www.example.com/bar.html
http://www.example.com/bla/?foo=bar + ../foo.html = http://www.example.com/foo.html

我很想知道,是否有埃尔兰·利布、C Lib或CLI方案,能够勾画给我的适当类别?

最佳回答

至CLI为止,wget 页: 1 转换:

  -B URL
  --base=URL

将URL作为参考点,在阅读通过——i/-input-file选项(与——force-html合并)规定的超文本文档链接时,或在输入文档与一个显示其为超文本的服务器相距时,确定相对链接。 这相当于在超文本输入档案中存在“BASE”标签,而URL作为“href”属性的价值。

For instance, if you specify http://foo/bar/a.html for URL, and Wget reads ../baz/b.html from the input file, it would be resolved to http://foo/baz/b.html.

因此,如果你把文件推到产出中去,然后用你的双兰文读,那就应该发挥作用。

问题回答

您可使用





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签