【问题标题】:Regex replace to map paginated URLs to a new format正则表达式替换以将分页 URL 映射到新格式
【发布时间】:2021-04-21 10:33:01
【问题描述】:

我正在使用网络爬虫工具来比较迁移前后两个不同的网站爬取,并且需要映射已更改格式的分页 URL。

例如

旧:https://example.com/page/2/ 或:https://example.com/directory/page/16/

新:https://example.com/?page=2 或:https://example.com/directory/?page=16

该工具具有用于 URL 映射的正则表达式替换功能,

但是,我无法使正则表达式正确,并且最终结果末尾有一个额外的正斜杠:

https://example.com/?page=2/

获取我正在寻找的结果的正确正则表达式是什么?

【问题讨论】:

    标签: regex url web-crawler regexp-replace


    【解决方案1】:

    正则表达式:/page/([0-9]+)/

    替换:/?page=$1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      • 2022-01-01
      • 1970-01-01
      相关资源
      最近更新 更多