Programming

Programming questions? Ask a programmer for answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

I need to get this script to return a dictionary in the following…

Customer Question
I need to get this...
I need to get this script to return a dictionary in the following format:
{'URLNAME.COM': 'YYYY-MM-DD'}

currently the output is

hookuplookuponline4.com
{'H': '08-jul-2010'}
so its replacing the entry rather than building me a dictionary, and the date is in the wrong format, please help, here is the code:

#!/usr/local/bin/python2.6
import MySQLdb
import os
import pywhois
import time
from datetime import *
# XXXXX database connection
db = MySQLdb.connect("localhost","domains","domains","domains" )

#define python whois expiraiton date function

def domainexpirationdate(x):
z = pywhois.whois(x)
z.expiration_date
return z.expiration_date
# XXXXX a cursor object using cursor() method
cursor = db.cursor()
select = """
select domain_name
from domain_info where datediff(expiration_date, now()) < 15
order by expiration_date asc
"""
cursor.execute(select)
data = cursor.fetchall()
for row in data:
URL = row[0]
expiredate = domainexpirationdate(row[0])
domain_status = dict(zip(URL, expiredate))


print domain_status
Submitted: 8 years ago.Category: Programming
Show More
Show Less
Ask Your Own Programming Question
Answered in 1 hour by:
6/24/2010
Programmer: Arty, Computer Software Engineer replied 8 years ago
Arty
Arty, Computer Software Engineer
Category: Programming
Satisfied Customers: 575
Experience: 15+ years of programming, C, C++, Java, PHP, awk, ruby, shell, ASM, Forth, Raptor, M.A.R.I.E, Excel
Verified

Hi.

 

Please try this code and let me know is it working.

 

Regards,

Arty

Ask Your Own Programming Question
Customer reply replied 8 years ago
Arty thanks for your quick response,

raceback (most recent call last):
File "./arty.py", line 33, in <module>
expiredate = domainexpirationdate(row[0])
File "./arty.py", line 18, in domainexpirationdate
l=z.expiration_date.split("-")
AttributeError: 'list' object has no attribute 'split'

here is the error the code is throwing
Programmer: Arty, Computer Software Engineer replied 8 years ago

Try this:

a=z.expiration_date

l=a.split("-")

 

instead of

;=z.expiraton_date.split("-")

 

 

Sorry for delay, it was night here.

 

Regards,

Arty

Ask Your Own Programming Question
Programmer: Arty, Computer Software Engineer replied 8 years ago
Try this version.
I have tested date conversions on python 2.6, didn't test database connection.

Regards,

Arty
Ask Your Own Programming Question
Customer reply replied 8 years ago
I actually figured it out, here was the issue, the date was returned as a time tuple when querying the database, so the current method of splitting did not work. when i did a ''.join(date) on the object, it converted it to a string, and strptime was able to re format it without an issue.


CMac
Programmer: Arty, Computer Software Engineer replied 8 years ago

Hi.

 

Glad to know it is working.

 

I've seen internals of pywhois and found an internal date parser, I recommend to use it instead (it is used in my last code).

 

There are 2 possible data formats returned by whois, both are equally valid: 2010-01-30 and 30-jan-2010. pythWhois parser is aware of these 2 formats and returns always a correct time value.

 

Regards,

Arty

Ask Your Own Programming Question
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a programmerLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask Arty Your Own Question
Arty
Arty
Arty, Computer Software Engineer
Category: Programming
Satisfied Customers: 575
575 Satisfied Customers
Experience: 15+ years of programming, C, C++, Java, PHP, awk, ruby, shell, ASM, Forth, Raptor, M.A.R.I.E, Excel

Arty is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

7,175 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

848 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
I want to add a feature to send an email if the download
I want to add a feature to send an email if the download speeds matches below 25. Here is the code. import os import re import csv import sys import math import errno import signal import socket impor… read more
George Sibiya
George Sibiya
PhD
313 satisfied customers
Python 2.7.12 script needed that takes an input file,
Python 2.7.12 script needed that takes an input file, modifies some of the fields and writes an output csv file in the desired format. read input file based on the start and month end dates entered by… read more
George Sibiya
George Sibiya
PhD
313 satisfied customers
I have a text file which contains the following: 106 Nerk,
I have a text file which contains the following: 106 Nerk, [email protected](NNN) NNN-NNNN 125 Mercau, [email protected](NNN) NNN-NNNN 114 Harrison, [email protected](NNN) NNN-NNNN 128 XXXXX, XXXXXX… read more
unvadim
unvadim
Computer Software Engineer
Diplom
1,168 satisfied customers
Having problems with MySQL and PHP. I am trying to scrape a
Having problems with MySQL and PHP. I am trying to scrape a website and save the values into a database.… read more
The-PC-Guy
The-PC-Guy
Software Engineer
Bachelor's Degree
848 satisfied customers
I have stored date and time in my calendar like mm/dd/yyyy
I have stored date and time in my calendar like mm/dd/yyyy h:mm and now I would like to display only the time in my calendar along with with other event data. I have some code written so get back with… read more
Tom
Tom
Systems Analyst
Bachelor\u0027s Degree
1 satisfied customers
I need help getting the landingpage for a session using
I need help getting the landingpage for a session using google analytics ga:landingPagePath. When i use the query below I get the correct result with my first visit using IE. However, when I close IE … read more
Chris L.
Chris L.
IT/Web Manager
Vocational, Technical or Trade Scho
30 satisfied customers
Question 1 Youve been going to work on a database project
Question 1 You've been going to work on a database project at work for sometime now. Your boss encourages you to program the database in Python. You disagree, arguing that Python is not a database lan… read more
Arty
Arty
Computer Software Engineer
Bachelor's Degree
575 satisfied customers
**For TheDoctor** Here a scenario> I need to be able to
**For TheDoctor** Here a scenario> I need to be able to update different record based on the result of a first query. If the first query does not return any record then no update is done and we mov… read more
TheDoctor
TheDoctor
Software Engineer
Master's Degree
893 satisfied customers
Trying to laern Python 2.7.3 withTony Gaddis book Starting
Trying to laern Python 2.7.3 withTony Gaddis book Starting out with Python. I have problems with defining variables. Even after adding ..bar after the mainbar name my code gives errors like NameError:… read more
dmoola
dmoola
Programmer
Bachelor\u0027s Degree
14 satisfied customers
How to Display DateTime At Y Axis using MSchart vb6? I have
How to Display DateTime At Y Axis using MSchart vb6? I have a program in which All data cases of program are being translating to array and passs it to MSChart1.chartdata. Dim MyChart(1 To 3, 1 To 3) … read more
Proggy
Proggy
Programmer
90 satisfied customers
The below query works when the @Startdate and @EndDate are
The below query works when the @Startdate and @EndDate are the same day i.e 4-17-2012 00:00:00 and 4-17-2012 23:59:59. I get 1 row retured with 3 shifts of data. However, when my Start and End dates s… read more
SDSU_GURU
SDSU_GURU
58 satisfied customers
the programming language is python i have a file that is XXXXXXXXX
the programming language is python i have a file that is XXXXXXXXX lines long. The file comes in blocks (repeats of four) of lines in which i will make a dictionary of the first and second lines of ea… read more
Arty
Arty
Computer Software Engineer
Bachelor's Degree
575 satisfied customers
I am trying to use a Flash extension that I downloaded from
I am trying to use a Flash extension that I downloaded from Adobe. xPriationDate is the title of the extension. However, when I compile my swf I receive several errors. I have attempted to contact the… read more
kweiner
kweiner
Consultant
Bachelor\u0027s Degree
141 satisfied customers
hello,um goitsemang in botswana diong computer science in university
hello,um goitsemang in botswana diong computer science in university of botswana,my question:prompt the user to enter a date using the YYYYMMDD format,read the date from the standard input stream,brea… read more
LogicPro
LogicPro
Computer Software Engineer
Bachelor of Technology
7,175 satisfied customers
Teacher added to the project. 1. Write a script that inputs
Teacher added to the project. 1. Write a script that inputs a line of plain text and a distance value and outputs an encrypted text using a Caesar cipher. The script should work for any printable char… read more
Brian H
Brian H
Senior Software Engineer
Master\u0027s Degree
55 satisfied customers
how can i make sure I select multiple events on a same date
how can i make sure I select multiple events on a same date once and populate its data. This is my code behind, just needs additional code to make this work. If you know please do let me know. protect… read more
John The Geek
John The Geek
Senior Software Developer
Bachelor\u0027s Degree
65 satisfied customers
Writing a program in Python to calculate the value of e - using
Writing a program in Python to calculate the value of e - using the sum of terms.? How to calculate the value of "e" using the sum of terms. The program should ask the user how many terms he wants to … read more
Todd
Todd
Bachelor\u0027s Degree
396 satisfied customers
I am having trouble with dates. Even though I format a column
I am having trouble with dates. Even though I format a column 03/06/09 I get some cells 3/6/09 In some cells I have to put the day in first to get the correct date, in others the month… read more
John D
John D
Bachelor Degree in Engineering
342 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x