小编R00*_*159的帖子

c#使用html agility pack不支持URI格式

我正在尝试使用HTML敏捷包让我的程序读取文件并从中获取所有图像srcs.这是我到目前为止得到的:

 private ArrayList GetImageLinks(String html,String link)
    {
        //link = url of webpage
        //html = a string of the html, just for testing will remove after

        HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
        htmlDoc.OptionFixNestedTags = true;
        htmlDoc.Load(link);
        List<String> imgs = (from x in htmlDoc.DocumentNode.Descendants()
                             where x.Name.ToLower() == "img"
                             select x.Attributes["src"].Value).ToList<String>();

        Console.Out.WriteLine("Hey");
        ArrayList imageLinks = new ArrayList(imgs);


        foreach (String element in imageLinks)
        {
            Console.WriteLine(element);

        }

        return imageLinks;
    }
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:System.ArgumentException:不支持URI格式.

c# html-agility-pack

3
推荐指数
1
解决办法
2701
查看次数

Java Jlist文本中心对齐

我有JList一个小组.

如何文本居中对齐JList?我似乎无法在模型的任何地方找到设置?

我已经在GUI上查找了对齐设置,但似乎无法在那里找到任何设置.

java swing alignment jlist

3
推荐指数
2
解决办法
8024
查看次数

在 perl 中覆盖文件

我该如何使用 Perl 用数组覆盖文件?

我的文件如下所示:

username1
comment
comment
comment
username2
comment
comment
username3
comment
comment
comment
...
Run Code Online (Sandbox Code Playgroud)

我所做的就是首先将这些行加载到数组中。然后遍历数组,将行添加到新数组中。当它找到用户的行时,我想向其添加注释,将触发一个标志,使其在循环的下一个增量中添加注释。然后它只是将其余的行添加到数组中。我想要做的就是使用新数组来覆盖文件。这就是我被困住的地方。

sub AddComment() {

  my $username = shift;    # the username to find
  my $comment  = shift;    # the comment to add
  chomp($comment);
  chomp($username);

  open my $COMMENTS, '<', "comments.txt" or die "$!";    #open the comments file
  my @lines = <$COMMENTS>;              #Make an array of the files lines

  my @NewCommentsFile;                  # make an array to store new file lines
  my $addCommentNow = 0;                # flag …
Run Code Online (Sandbox Code Playgroud)

perl

1
推荐指数
1
解决办法
9251
查看次数

标签 统计

alignment ×1

c# ×1

html-agility-pack ×1

java ×1

jlist ×1

perl ×1

swing ×1