So my Array contains this data
Abonnenten = ["https://www.instagram.com/vivksj/",
"https://www.instagram.com/aaalink/",
"https://www.instagram.com/haanannnnna/",
"https://www.instagram.com/tiigergirlxofical/",
"https://www.instagram.com/patriiciaa.015/",
"https://www.instagram.com/itss_leonie_/",
"https://www.instagram.com/patriciawk/",
"https://www.instagram.com/taelly.scr/",
"https://www.instagram.com/mozzhliana/",
"https://www.instagram.com/mialecdron/"]
Because of data protection i changed the usernames, but you get the example. In my code i want to browse through a few selected users of instagram. If they have their snapchat linked in their bio like so:
for i in range(len(Abonnenten)):
driver.get(Abonnenten[i])
# get the text from their instagram bio
try:
wait = WebDriverWait(driver, 10)
bio = wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class='-vDIg']/span"))).text
Snapnames = list.append(bio)
print(Snapnames)
Here i wanted to try to get all the snapchat names my app found to print out. But i couldn´t figure out that.
# check if text contains "snapchat"
if ("snapchat" in bio):
# split the instagram bio by newline char to get line with snapchat name
bio_lines = bio.split("\n")
# parse over the instagram bio to find snapchat username
for line in bio_lines:
# if we find the line with username, strip out text to get the username
if ("Snapchat:" in line):
#snapchat_username = []
snapchat_username = line.replace[("Snapchat:", "")]
# you probably need to do something here to save to file
print(snapchat_username)
Although those code lines are commented i can´t figure out what they do or if they work.
# case: the user does not have a bio, so just move on to the next one
except TimeoutException:
continue
i = i + 1
the last lines of code should be self explaining. Once again, i want to scrap a instagram users bio for his/her snapchat name and if they have one it saves it to a list or array so i can either give it out as a file or print it out. (i use the chromedriver)