Python Forum
Need Help Understanding Python Code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help Understanding Python Code
#1
I need help explaining this code that was given to me. I understand the simple ones like lines 1-4, and 9-10 and have a tough time understanding the rest of that portion of the code.
indexHTML = requests.get("https://www.gosolarcalifornia.ca.gov/equipment/documents/").text
fileName = "Grid_Support_Inverter_List_Full_Data.xlsm"
fileNameHTML = '<td><a href="{0}">{0}</a></td>'.format(fileName)
fileNameHTMLIndex = indexHTML.find(fileNameHTML)
if fileNameHTMLIndex != -1:
    dateStartIndex = indexHTML.find(">", fileNameHTMLIndex+len(fileNameHTML)) + 1
    dateEndIndex = indexHTML.find("<", dateStartIndex)
    webFileDate = datetime.datetime.strptime(indexHTML[dateStartIndex:dateEndIndex].strip(), "%Y-%m-%d %H:%M")
else:
    raise Exception("Unable to find fileName {}".format(fileName))
Reply


Messages In This Thread
Need Help Understanding Python Code - by samlee916 - Jan-03-2020, 03:02 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020