I have a link which contains mail id's and I want to count the mails with same domain's. I have to take input from the URL.
import requests
def finddomains(input_):
domainFre = dict()
ans = []
for i in range(len(input_)):
findindex = input_[i].index('@')
if input_[i][findindex + 1::] in domainFre:
domainFre[input_[i][findindex + 1::]] += 1
else:
domainFre[input_[i][findindex + 1::]] = 1
for it in domainFre:
ans.append([it, domainFre[it]])
ans.sort()
return ans
# Driver Code
link = "url"
input_ = requests.get(link)
ans = []
ans = finddomains(input_)
for i in range(len(ans)):
print(ans[i][0], ans[i][1])
error message : --> 10 for i in range(len(input_)): 11 12 findindex = input_[i].index('@')
TypeError: object of type 'Response' has no len()
try
ans = finddomains(input_.text)
or
ans = finddomains(input_.json)
these will retrun a dict
you can loop throw them and find the data you needed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.