Hi, how are you? I'm Parin, who recently introduced Python.
Result value
tldextract [result] | sort | uniq | grep.com | tr -d'',
Like this
twitter com
weheartit com
www facebook com
www pinterest com
www reddit com
www youtube com
I just want to get regular expression information about the domain like this I don't know how to use Unix regular expressions in Python.
<Original Code >
import requests, json, os
url = "http://localhost:5000/search"
data = {
"image_url":"http://www.mrtt.news/news/photo/201806/147_281_1930.jpg",
"resized_images":True # Or true
}
headers = {'Content-type': 'application/json'}
r = requests.post(url, headers=headers, data=json.dumps(data))
//r.json to get the response as json
print(r.json())
After executing the above code Result value
tldextract [result] | sort | uniq | grep.com | tr -d'',
I looked it up because I wanted to get it from, and I heard that a module called subprocess helps me use Unix code, so I modified the code as follows.
AttributeError: module 'subprocess' has no attribute 'a'
This error is coming out
This is the code that I modified.
cat example1.py
import requests, json
import subprocess
url = "http://localhost:5000/search"
data = {
"image_url":"http://www.mrtt.news/news/photo/201806/147_281_1930.jpg",
"resized_images":True # Or true
}
headers = {'Content-type': 'application/json'}
r = requests.post(url, headers=headers, data=json.dumps(data))
//r.json to get the response as json
a = r.json()
imageURL = subprocess.a
image = imageURL.check_output('| sort | uniq | grep .com | tr -d ','')
print(image)
How can I make corrections to get the value that I want?
subprocess json tldextract python
The tldextract is available as a module, so you can use it as shown in the example below without having to fork the process.
>>> import tldextract
>>> tldextract.extract('http://forums.news.cnn.com/')
ExtractResult(subdomain='forums.news', domain='cnn', suffix='com')
>>> tldextract.extract('http://forums.bbc.co.uk/') # United Kingdom
ExtractResult(subdomain='forums', domain='bbc', suffix='co.uk')
>>> tldextract.extract('http://www.worldbank.org.kg/') # Kyrgyzstan
ExtractResult(subdomain='www', domain='worldbank', suffix='org.kg')
If you have to fork it, use it in the format below.
subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False, timeout=None)
import subprocess
subprocess.call(["ls", "-l"])
© 2024 OneMinuteCode. All rights reserved.