Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 我只想用以http开头的google.com替换参数_Python 3.x_Bash_Script - Fatal编程技术网

Python 3.x 我只想用以http开头的google.com替换参数

Python 3.x 我只想用以http开头的google.com替换参数,python-3.x,bash,script,Python 3.x,Bash,Script,我有一个包含如下URL列表的.txt文件,我只想用google.com替换那些以http开头的所有参数 Example.txt文件输入: https://example.com?url=https://sub.abc.com&id=1 https://example.com?url=https://sub.abc.com&id=1&res=false https://example.com?redirect=https://sub.abc.com&name=tes

我有一个包含如下URL列表的.txt文件,我只想用google.com替换那些以
http
开头的所有参数

Example.txt文件输入:

https://example.com?url=https://sub.abc.com&id=1
https://example.com?url=https://sub.abc.com&id=1&res=false
https://example.com?redirect=https://sub.abc.com&name=test&verify=false&url=https//evil.com
https://example.com?id=1&refer=http://yahoo.com
https://example.com?url=https://google.com&id=1
https://example.com?url=https://google.com&id=1&res=false
https://example.com?redirect=https://google.com&name=test&verify=false&url=https://google.com
https://example.com?id=1&refer=http://google.com
我想要在txt文件中的输出:

https://example.com?url=https://sub.abc.com&id=1
https://example.com?url=https://sub.abc.com&id=1&res=false
https://example.com?redirect=https://sub.abc.com&name=test&verify=false&url=https//evil.com
https://example.com?id=1&refer=http://yahoo.com
https://example.com?url=https://google.com&id=1
https://example.com?url=https://google.com&id=1&res=false
https://example.com?redirect=https://google.com&name=test&verify=false&url=https://google.com
https://example.com?id=1&refer=http://google.com

注意:我只想替换以
http

开头的参数。您是希望在bash脚本中还是在Python中使用它?您自己做了哪些尝试?您面临的确切问题是什么?我只想要上面显示的所需输出,无论是python还是bash……。我使用了tomnomnom的一个工具,它可以做这些事情,但我唯一面临的问题是,该工具将所有参数替换为给定的字符串………但我只想替换那些以字符串开头的参数值http…….这不是一个编码编写服务:您编写一个程序或脚本,如果您有问题,我们可能会帮助您克服它们。