Getting my IP using python -
i trying update rackspace dns ip using python script.
my script works when manually come in ip in it, dosen't when outside, why?
this works:
#!/usr/bin/env python import clouddns import requests r= requests.get(r'http://curlmyip.com/') ip= '4.4.4.4' dns = clouddns.connection.connection('******','********************') domain = dns.get_domain(name='reazem.net') record = domain.get_record(name='ssh.reazem.net') record.update(data=ip, ttl=600) this doesn't:
#!/usr/bin/env python import clouddns import requests r= requests.get(r'http://curlmyip.com/') **ip= '{}'.format(r.text)** dns = clouddns.connection.connection('******','********************') domain = dns.get_domain(name='reazem.net') record = domain.get_record(name='ssh.reazem.net') record.update(data=ip, ttl=600) note: print '{}'.format(r.text) succesfully outputs ip.
helping helping me: noticed print '{}'.format(r.text) adds line, how avoid that?
for interested: https://github.com/rackspace/python-clouddns
try ip = r.text.strip() remove newline.
python
No comments:
Post a Comment