Problem with save in csv information of web scraping - python

I am working on retrieving information from pages through web scraping, my code does not throw errors, but I have problems wanting to save this information in a kind of database. I leave my code to see if anyone can help me, I create the csv file, but at the moment, it saves absolutely nothing:
import requests
from bs4 import BeautifulSoup
import csv
from urllib.request import urlopen
#MOTOR DE BUSQUEDA
#Rastreo de sitios a traves de la barra de búsqueda
class Content: #Pensamos las noticias como objetos o elementos, por ende creamos la clase Content para extraer el contenido del sitio "el ciudadano"
def __init__(self, topic, url, title, body, data): #se crea de esta forma una clase, donde tenemos el titulo, el cuerpo, la url y el topico de búsqueda.
self.topic = topic #leemos la palabra clave de búsqueda
self.title = title #leemos el titulo
self.body = body #leemos el cuerpo
self.url = url #leemos la URL
self.data = data #leemos la fecha de publicación
def print(self):
print("New article found for topic: {}".format(self.topic))
print("TITLE: {}".format(self.title))
print("BODY:\n{}".format(self.body))
print("URL: {}".format(self.url))
print("DATA: {}".format(self.data))
class Website: #Clase que guarda las propiedades del sitio
"""
Contiene informacion sobre la estructura del sitio web
"""
def __init__(self, name, url, searchUrl, resultListing, resultUrl, absoluteUrl, titleTag, bodyTag, dataTag):
self.name = name
self.url = url
self.searchUrl = searchUrl #contiene al boton de busqueda
self.resultListing = resultListing #elemento que ve en resultado todas las listas encontradas
self.resultUrl = resultUrl #define la etiqueta donde se encuentra el link que queremos acceder
self.absoluteUrl=absoluteUrl #creamos el valor boleano para ver si la url es absoluta o relativa,
#absoluta = True relativa=False
self.titleTag = titleTag #etiqueta del titulo de la noticia
self.bodyTag = bodyTag #etiqueta del cuerpo de la noticia
self.dataTag = dataTag #etiqueta de la fecha de publicacion de la noticia
class Crawler: #Clase que toma la URL y devuelve el objeto BeautifulSoup
#Aqui trata las excepciones y posibles errores
def getPage(self, url): #funcion que toma una url y devuelve un objeto BeautifulSoup
try:
req = requests.get(url)
except requests.exceptions.RequestException:
return None
return BeautifulSoup(req.text, 'html.parser')
#funcion de utilidad que nos encontrara los elementos dentro del BeautifulSoup
def safeGet(self, pageObj, selector):
childObj = pageObj.select(selector)
if childObj is not None and len(childObj) > 0:
#return childObj[0].get_text() solo entrega el primero
return '\n'.join(
[elem.get_text() for elem in childObj]) #entrega todos las busquedas
return "" #Si no pasa eso, retorna vacio o none.
def search(self, topic, site): #ingresamos un tópico y el sitio
"""
Busca en un sitio web determinado un tema determinado y registra todas las paginas
encontradas
"""
bs = self.getPage(site.searchUrl + topic) #recibe la URL del sitio con el tópico
searchResults = bs.select(site.resultListing) #definimos el objeto que contiene todos los resultados
registrocontenido = []
for result in searchResults: #como son varios, accedimos uno por uno
url = result.select(site.resultUrl)[0].attrs["href"] #el atributo href contiene los links
# Verifica si es una URL relativa o absoluta.
if(site.absoluteUrl):
bs = self.getPage(url) #si es absoluta
else:
bs = self.getPage(site.url + url) #si es relativa
if bs is None:
print("Tenemos un problema!!")
return
title = self.safeGet(bs, site.titleTag) #usamos la funcion de utilidad safeGet
body = self.safeGet(bs, site.bodyTag)
data = self.safeGet(bs, site.dataTag)
if title != '' and body != '':
#Si titulo y cuerpo son distintos de vacios, imprimos.
content = Content(topic, url, title, body, data)
content.print()
registrocontenido.append(content)
return registrocontenido
def writeArticles(filename, articles):
csvFile = open(filename,'wt+',encoding='utf-8')
writer=csv.writer(csvFile)
try:
for article in articles:
csvrow = [article,topic,article.title,article.data,article.body,article.url]
finally:
csvFile.close()
crawler = Crawler()
#siteData=[nombre, urlprincipal,url busqueda, etiquetaresultado,etiqueta título en lista de resultados,url absoluta,titulo de la noticia, cuerpo, fecha]
siteData = [['El ciudadano', 'https://www.elciudadano.com/', 'https://www.elciudadano.com/?s=', 'div.td_module_16 ','h3.entry-title a', True, 'h1.entry-title', 'div.td-post-content p', 'time']]
sites = []
for row in siteData:
sites.append(Website(row[0], row[1], row[2],row[3], row[4], row[5], row[6], row[7], row[8]))
topics = ['PYTHON'] #variable de topicos que queremos extraer
articles = []
for topic in topics:
print("GETTING INFO ABOUT: " + topic)
for targetSite in sites: #for para recorrer los sitios
articles.extend(crawler.search(topic, targetSite))
crawler.search(topic, targetSite) #llamamos a la funcion search
writeArticles('Articulos.csv', articles)
I appreciate any help or suggestion please!

In your method to save the content to csv, you are not writing to the file. the code just opens and closes the file pointer. Use writer.writerow()
def writeArticles(filename, articles):
csvFile = open(filename,'wt+',encoding='utf-8')
writer=csv.writer(csvFile)
try:
for article in articles:
writer.writerow([article,topic,article.title,article.data,article.body,article.url])
finally:
csvFile.close()

Related

Get full text below h2 tag with BeautifulSoup

I am trying to obtain different character's descriptions and habilities for a dataset.
The problem I've encountered is that there seems to be a span tag within the h2 tag and in some cases a figure before de p tags. This is the format I'm facing:
<h2><span class="mw-headline" id="Apariencia">Apariencia</span></h2>
<figure class="thumb tleft " style="width: 100px">
<p>...</p>
<p>...</p>
<p>...</p>
<h2><span class="mw-headline" id="Personalidad">Personalidad</span></h2>
<p>...</p>
<p>...</p>
<p>...</p>
I need to obtain the text in those paragraphs.
I have tried something like this but it obviously does not work.
import urllib.request
from bs4 import BeautifulSoup
fp = urllib.request.urlopen("https://jojo.fandom.com/es/wiki/Star_Platinum")
mybytes = fp.read()
html_doc = mybytes.decode("utf8")
fp.close()
soup = BeautifulSoup(html_doc, 'html.parser')
spans = soup.find_all('span', {"class": "mw-headline"})
for s in spans:
print(s.nextSibling.getText)
You can search backwards for previous <h2> and store result in the dictionary:
from bs4 import BeautifulSoup
html_doc = '''\
<h2><span class="mw-headline" id="Apariencia">Apariencia</span></h2>
<figure class="thumb tleft " style="width: 100px">
<p>T1 ...</p>
<p>T2 ...</p>
<p>T3 ...</p>
<h2><span class="mw-headline" id="Personalidad">Personalidad</span></h2>
<p>T4 ...</p>
<p>T5 ...</p>
<p>T6 ...</p>'''
soup = BeautifulSoup(html_doc, 'html.parser')
out = {}
for p in soup.select('p'):
previous_h2 = p.find_previous('h2')
out.setdefault(previous_h2.text, []).append(p.text)
print(out)
Prints:
{
'Apariencia': ['T1 ...', 'T2 ...', 'T3 ...'],
'Personalidad': ['T4 ...', 'T5 ...', 'T6 ...']
}
I think in this case, .select with CSS selectors would be very useful.
To get all the section headers, you can use the selector h2:has(span.mw-headline[id]); and to get a specific header by the id attribute value (hId below) of the span nested within, you can use the selector hSel below.
hId = 'Personalidad' # for example
hSel = f'h2:has(span.mw-headline[id="{hId}"])'
Then, to get all the tags after that header, you can use f'{hSel}~*', but you also need to filter out the tags after the next header to only get tags in that section, so the full selector would be
sSel = f'{hSel}~*:not({hSel}~h2~*):not(h2)'
[:not({hSel}~h2~*) filters out the tags after the next header, and :not(h2) filters out the next header tag itself.]
Making use of this, the function below returns a dictionary containing section header, text and html.
def get_wikiSection(header, wSoup, sec1Header='? Abstract ?'):
sSel = 'h2:has(span.mw-headline[id])'
sSel = f'*:has(~{sSel}):not({sSel}~*)'
if not header: hId = hSel = None # [first section has no header]
elif isinstance(header, str):
hId, hSel = header, f'h2:has(span.mw-headline[id="{header}"])'
header = wSoup.select_one(hSel)
if not header: return {'errorMsg': f'Not found: {hSel}'}
else: hId = header.select_one('span.mw-headline[id]')['id']
## header SHOULD BE: None/hId/a tag containing span.mw-headline[id] ##
if hId:
hSel = f'h2:has(span.mw-headline[id="{hId}"])'
sSel = f'{hSel}~*:not({hSel}~h2~*):not(h2)'
header = header.get_text(' ').strip()
else: header = sec1Header
sect = wSoup.select(sSel)
sText = '\n'.join([s.get_text(' ').strip() for s in sect])
sHtml = '\n'.join([''.join(s.prettify().splitlines()) for s in sect])
if not sect: sText = sHtml = None
return {'headerId': hId, 'sectionHeader': header,
'sectionText': sText, 'sectionHtml': sHtml}
For example, get_wikiSection('Personalidad', soup) will return
{
'headerId': 'Personalidad',
'sectionHeader': 'Personalidad',
'sectionText': 'Jotaro describió a Star Platinum como un ser muy violento. Suele ser silencioso, excepto cuando lanza golpes, gritando "ORA ORA ORA" en voz alta, bastante rápido y repetidamente. Con una cara relativamente humana ha demostrado tener expresiones tales como fruncir el ceño y sonreír.\nStar Platinum demuestra un tipo de interés en la auto-conservación, como se ve cuando detiene una bala que Jotaro dispara experimentalmente en su propia cabeza, protege a un Jotaro incapacitado de los ataques de DIO durante los efectos de su The World , y lo revive de cerca de la muerte directamente hacia latir su corazón (Sin embargo, considerando el papel pionero de Star Platinum en la serie, esta capacidad puede hablar principalmente de cualidades metafísicas o subconscientes genéricas para los usuarios de Stand).\nEn el manga original, Star Platinum desde el principio se ve con una sonrisa amplia y desconcertante. Más tarde, Star Platinum gana el rostro estoico de Jotaro, cualquier sonrisa futura va a advertir a la persona que se dirige a un gran dolor inminente.\nStar Platinum lleva el nombre de la carta del Tarot La Estrella , que simboliza el optimismo, el discernimiento y la esperanza.',
'sectionHtml': '<p> Jotaro describió a Star Platinum como un ser muy violento. Suele ser silencioso, excepto cuando lanza golpes, gritando "ORA ORA ORA" en voz alta, bastante rápido y repetidamente. Con una cara relativamente humana ha demostrado tener expresiones tales como fruncir el ceño y sonreír.</p>\n<p> Star Platinum demuestra un tipo de interés en la auto-conservación, como se ve cuando detiene una bala que Jotaro dispara experimentalmente en su propia cabeza, protege a un Jotaro incapacitado de los ataques de DIO durante los efectos de su The World , y lo revive de cerca de la muerte directamente hacia latir su corazón (Sin embargo, considerando el papel pionero de Star Platinum en la serie, esta capacidad puede hablar principalmente de cualidades metafísicas o subconscientes genéricas para los usuarios de Stand).</p>\n<p> En el manga original, Star Platinum desde el principio se ve con una sonrisa amplia y desconcertante. Más tarde, Star Platinum gana el rostro estoico de Jotaro, cualquier sonrisa futura va a advertir a la persona que se dirige a un gran dolor inminente.</p>\n<p> Star Platinum lleva el nombre de la carta del Tarot <a class="extiw" href="http://en.wikipedia.org/wiki/es:La_Estrella_(Tarot)" title="wikipedia:es:La Estrella (Tarot)"> La Estrella </a> , que simboliza el optimismo, el discernimiento y la esperanza.</p>'
}
If you want all the sections:
h2Tags = soup.select('h2:has(span.mw-headline[id])')
wikiSections = [get_wikiSection(h, soup) for h in [None]+h2Tags]
The resulting list of dictionaries can also be converted to a pandas DataFrame as simply as pd.DataFrame(wikiSections).

Separate list obtained with selenium Python

I am developing a script to scrape a page of hotels.com with selenium
import time
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
import pandas as pd
import csv
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get('https://es.hoteles.com/ho227810/secrets-lanzarote-resort-spa-adults-only-18-yaiza-espana/')
time.sleep(3)
try:
cookies = driver.find_element(By.CLASS_NAME, 'osano-cm-button--type_accept')
cookies.click()
time.sleep(2)
except:
pass
try:
tamano_hotel = driver.find_elements(By.XPATH, '//*[#id="Amenities"]/div/div[1]/div/div[2]')
hotel=[]
for iterarhotel in tamano_hotel:
hotel.append(iterarhotel.text)
print(hotel)
time.sleep(2)
except:
print("Nothing")
It extracts it as a list
['Tamaño del hotel\n331 habitaciones\nCuenta con 8 pisos\nEntrada y salida\nHorario del registro de entrada: de 15:00 a 0:00\nEdad mínima para efectuar el registro de entrada: 18\nSe puede efectuar el registro de salida hasta las 12:00\nRestricciones relacionadas con tu viaje\nConsulta las restricciones por el COVID-19.\nInstrucciones especiales de entrada\nEl personal de recepción estará esperando a los huéspedes a su llegada.\nPara obtener más información, ponte en contacto con el alojamiento a través de los datos que aparecen en la confirmación de la reserva.\nLos restaurantes del establecimiento abren en función de la temporada.\nDocumentación para el registro de entrada\nEs obligatorio presentar una tarjeta de crédito o de débito, o dejar un depósito en efectivo, para posibles cargos adicionales.\nPueden pedirte un documento de identidad válido.\nLa edad mínima para alojarse en este alojamiento es de 18 años\nLa edad mínima para realizar el registro de entrada es de 18 años.\nMenores\nCunas no disponibles\nMascotas\nSe admiten mascotas (solo perros y gatos, 1 por habitación hasta 10 kg)*\nCon restricciones*\nInternet\nConexión wifi gratis en las zonas comunes\nConexión wifi gratis en las habitaciones\nAparcamiento\nAparcamiento sin asistencia gratuito en las instalaciones\nAparcamiento para coches accesible en silla de ruedas en las instalaciones\nTraslados\nTraslado desde/hasta el aeropuerto*\nInformación adicional\nAlojamiento para no fumadores\nSolo para adultos']
I am trying to scrape the Amenities part but I get the list all together, how could I separate it in a way that it would be separated like this?
Tamaño del hotel: 331 habitaciones, Cuenta con 8 pisos
Entrada y salida: Horario del registro de entrada: de 15:00 a 0:00, Edad mínima para efectuar el registro de entrada: 18, Se puede efectuar el registro de salida hasta las 12:00
Restricciones relacionadas con tu viaje: Consulta las restricciones por el COVID-19.
etc...
Create an empty dictionary object and add the key as header and value and li elements.
I have changed the locator as well.
try:
tamano_hotel = driver.find_elements(By.CSS_SELECTOR, 'section#Amenities div.uitk-layout-columns-item')
hotel=[]
dictdetails={}
for iterarhotel in tamano_hotel:
dictdetails[iterarhotel.find_element(By.XPATH, ".//h3").text]=",".join([item.text for item in iterarhotel.find_elements(By.XPATH, ".//ul//li")])
hotel.append(dictdetails)
print(hotel)
time.sleep(2)
except:
print("Nothing")
Console output:
[{'Tamaño del hotel': '331 habitaciones,Cuenta con 8 pisos', 'Entrada y salida': 'Horario del registro de entrada: de 15:00 a 0:00,Edad mínima para efectuar el registro de entrada: 18,Se puede efectuar el registro de salida hasta las 12:00', 'Restricciones relacionadas con tu viaje': 'Consulta las restricciones por el COVID-19.', 'Instrucciones especiales de entrada': 'El personal de recepción estará esperando a los huéspedes a su llegada.,Para obtener más información, ponte en contacto con el alojamiento a través de los datos que aparecen en la confirmación de la reserva.,Los restaurantes del establecimiento abren en función de la temporada.', 'Documentación para el registro de entrada': 'Es obligatorio presentar una tarjeta de crédito o de débito, o dejar un depósito en efectivo, para posibles cargos adicionales.,Pueden pedirte un documento de identidad válido.,La edad mínima para alojarse en este alojamiento es de 18 años,La edad mínima para realizar el registro de entrada es de 18 años.', 'Menores': 'Cunas no disponibles', 'Mascotas': 'Se admiten mascotas (solo perros y gatos, 1 por habitación hasta 10 kg)*,Con restricciones*', 'Internet': 'Conexión wifi gratis en las zonas comunes,Conexión wifi gratis en las habitaciones', 'Aparcamiento': 'Aparcamiento sin asistencia gratuito en las instalaciones,Aparcamiento para coches accesible en silla de ruedas en las instalaciones', 'Traslados': 'Traslado desde/hasta el aeropuerto*', 'Información adicional': 'Servicio de limpieza diario,Caja fuerte', 'Comida y bebida': '6 restaurantes,5 bares o lounges,Bar junto a la piscina,Cafetería,Café y té en una zona común,Servicio de habitaciones las 24 horas,Snack-bar o delicatessen', 'Actividades': 'Tenis,Ráquetbol o squash,Vóleibol,Submarinismo,Cerca de la playa,Rutas a pie o en bicicleta en las inmediaciones,Ciclismo de montaña en las inmediaciones,Kayak en las inmediaciones,Esnórquel en las inmediaciones,Alquiler de ciclomotores o scooters en las inmediaciones', 'Teletrabajo': 'Centro de negocios abierto las 24 horas,5 salas de reuniones,Sala de ordenadores,Centro de conferencias de 1899 metros cuadrados']

crawler to follow links and get information from links python

Guys I need to make a bot that will collect some information from links, it will first go to this link https://www.mediktor.com/pt-br/glossario and get the links to all the diseases and then go one by one and get their information like description, epidemiology, symptoms and etc. I came up with this code where it can get the links but it doesn't return anything when I try to access them and get the information
import scrapy
import time
import requests
import pandas as pd
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import json
class DicionarioSpider(scrapy.Spider):
name = 'dicionario'
allowed_domains = ['www.mediktor.com']
start_urls = ['http://www.mediktor.com/']
def start_requests(self):
url = "https://www.mediktor.com/pt-br/glossario"
options = Options()
options.headless = True
driver = webdriver.Chrome(options=options)
driver.get(url)
time.sleep(10)
doencas = driver.find_elements(
By.XPATH, "//a[#class='mdk-dictionary-list__glossary-item']")
for doenca in doencas:
url = doenca.get_attribute('href')
yield scrapy.Request(url)
driver.quit()
def parse(self, response):
urls = response.css(
'.mdk-dictionary-list__glossary-item a::attr(href)')
for url in urls:
yield response.follow(url.get(), callback=self.parse_info)
def parse_info(self, response):
contents = response.css('div.page-glossary-detail__main-content')
for desc in response.css('div.mdk-conclusion-detail__main-description'):
desc = response.css('p ::text').getall()
yield {
'desc': desc
}
for content in contents:
yield{
'name': content.css(
'div.mdk-conclusion-detail__main-title ::text').get().strip(),
'espec': content.css(
'div.mdk-ui-list-item__text mdc-list-item__text span::text').strip()
}
the data is dynamically loaded, you can get all possible IDs, and one by one go through and get information on them. In my example, getting the first one from the list, and a huge JSON from which you will get all the necessary data. I had to cut off part of it because of the character limit
import pandas as pd
import requests
from bs4 import BeautifulSoup
def get_auth_code():
url = "https://www.mediktor.com/vendor.js"
response = requests.get(url)
start_index = response.text.index('APP_API_AUTH_CODE:"', 0) + len('APP_API_AUTH_CODE:"')
end_index = response.text.index('"', start_index)
return response.text[start_index:end_index]
def get_auth_token_and_device_id():
url = "https://euapi01.mediktor.com/backoffice/services/login"
payload = "{\"useCache\":0,\"apiVersion\":\"4.1.1\",\"appVersion\":\"8.7.0\"," \
"\"appId\":null,\"deviceType\":\"WEB\",\"deviceToken\":null,\"language\":\"en_EN\"," \
"\"timezoneRaw\":180,\"authTokenRefreshExpiresIn\":null}"
headers = {
'authorization': f'Basic {get_auth_code()}',
'Content-Type': 'text/plain'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()['authToken'], response.json()['deviceId']
def get_conclusion_list(auth_token, device_id):
url = "https://euapi01.mediktor.com/backoffice/services/conclusionList"
payload = "{\"useCache\":168,\"apiVersion\":\"4.1.1\",\"appVersion\":\"8.7.0\"" \
",\"appId\":null,\"deviceType\":\"WEB\",\"deviceToken\":null,\"language\":\"pt_BR\"," \
"\"timezoneRaw\":180,\"deviceId\":\"" + device_id + "\"}"
headers = {
'accept': 'application/json, text/plain, */*',
'authorization': f'Bearer {auth_token}',
'content-type': 'application/json;charset=UTF-8'
}
response = requests.request("POST", url, headers=headers, data=payload)
return [conclusionId['conclusionId'] for conclusionId in response.json()['conclusions']]
def get_details(conclusionId, auth_token, device_id):
url = "https://euapi01.mediktor.com/backoffice/services/conclusionDetail"
payload = "{\"useCache\":0,\"apiVersion\":\"4.1.1\",\"appVersion\":\"8.7.0\"," \
"\"appId\":null,\"deviceType\":\"WEB\",\"deviceToken\":null,\"language\":\"pt_BR\"," \
"\"timezoneRaw\":180,\"deviceId\":\"" + device_id + "\"," \
"\"conclusionId\":\"" + conclusionId + "\"," \
"\"conclusionTemplate\":\"conclusion_description_body\",\"includeActions\":true}"
headers = {
'authorization': f'Bearer {auth_token}',
'content-type': 'application/json;charset=UTF-8'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.text
auth_token, device_id = get_auth_token_and_device_id()
conclusion_list = get_conclusion_list(auth_token, device_id)
for conclusion in conclusion_list[:1]:
print(get_details(conclusion, auth_token, device_id))
OUTPUT:
{"conclusion":{"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","description":"Pitiríase rósea de Gibert (Pediatria)","descriptionMap":{"it_IT":["Pitiriasi rosea di Gibert (Pediatria)"],"el_GR":["Ροδόχρους πιτυρίαση Gilbert (Παιδιατρική)"],"fr_BE":["Pityriasis rosé de Gibert (Pédiatrie)"],"nl_BE":["Pityriasis rosea van Gibert (Pediatrie)"],"pt_BR":["Pitiríase rósea de Gibert (Pediatria)"],"fr_FR":["Pityriasis rosé de Gibert (Pédiatrie)"],"ca_ES":["Pitiriasi rosada de Gibert (Pediatria)"],"de_DE":["Röschenflechte - Pityriasis rosea (Kinderheilkunde)"],"en_US":["Pityriasis rosea Gibert (Pediatrics)"],"es_MX":["Pitiriasis rosada de Gibert (Pediatría)"],"zh_CN":["玫瑰糠疹 (儿科)"],"es_ES":["Pitiriasis rosada de Gibert (Pediatría)"],"en_EN":["Pityriasis rosea Gibert (Paediatrics)"],"pt_PT":["Pitiríase rósea de Gibert (Pediatria)"]},"lastEdited":1650459591108,"frequency":0.2,"frequencyEnum":0,"descriptionHeaderImage":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=45c9a541-dbfc-41fe-8b73-76d021b245a1&d=1596042153781&b&l=1920","descriptionExtendedManagerFullName":"Dr Maria Trabazo","lastEditedGlobalFormattedToDay":"20/05/2022","severity":0.05,"severityEnum":0,"icd9":"696.3","icd10":"L42","specialties":["Dermatologia","Pediatria"],"specialtyIdList":["11","32"],"hasDescriptionExtended":true,"images":["https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=45c9a541-dbfc-41fe-8b73-76d021b245a1&d=1596042153781&b&l=1920","https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=9cd01ae5-383b-481a-92a8-518fe4dc3a9d&d=1560963312374&b&l=1920","https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=02202660-d437-4f91-b0c1-3cd35efb6663&d=1500652985149&b&l=1920"],"mediaFileList":[{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=45c9a541-dbfc-41fe-8b73-76d021b245a1&d=1596042153781&b&l=1920","copyright":"© Copyright TeckelMedical","description":"Pitiríase rósea de Gibert","type":1},{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=9cd01ae5-383b-481a-92a8-518fe4dc3a9d&d=1560963312374&b&l=1920","copyright":"© Copyright BIODERMA PRO","description":"Pitiríase de Gibert","type":1},{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=02202660-d437-4f91-b0c1-3cd35efb6663&d=1500652985149&b&l=1920","copyright":"© Copyright TeckelMedical","description":"Pitiríase rósea de Gibert","type":1}],"actionList":[],"specialtyList":[{"categoryId":"11","specialtyId":"11","name":"Dermatologia","descriptionExtended":"<p>Especialidade que estuda, diagnostica e trata doenças da pele.</p>\n\n<p>Existem subespecialidades da dermatologia como, por exemplo, a dermatologia pediátrica, dermatologia cosmética, etc.</p>","image":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=bfbba59f-806d-43a7-a5c4-cbde2210143b&d=1477780137091&b&l=960","propertyValueList":[{"propertyId":"b9d82cad-1911-4fb6-b764-21fc25cf0341","name":"Código de especialidade do Medicare","value":"7"},{"propertyId":"593639e8-6423-4597-8801-3e362c1f9b7d","name":"OMC Id","value":"16"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"394582007"}],"isActive":true,"lastEdited":1657546400463,"typeMask":1048580,"isExclusive":false,"isSpecialty":true,"isHomeSection":false,"shownOrder":100,"tintColor":"#FF03A6A6","statements":[]},{"categoryId":"32","specialtyId":"32","name":"Pediatria","descriptionExtended":"<p>Especialidade que estuda, diagnostica, trata e previne doenças da infância.</p>\n\n<p>Engloba desde o nascimento até a adolescência, que, dependendo do país, varia desde os 16 aos 18 anos.</p>","image":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=b2dca339-eee3-479f-9545-67f6d9872cc2&d=1477779967750&b&l=960","propertyValueList":[{"propertyId":"b9d82cad-1911-4fb6-b764-21fc25cf0341","name":"Código de especialidade do Medicare","value":"37"},{"propertyId":"593639e8-6423-4597-8801-3e362c1f9b7d","name":"OMC Id","value":"2"}],"isActive":true,"lastEdited":1657546400456,"typeMask":4,"isExclusive":false,"isSpecialty":true,"isHomeSection":false,"shownOrder":100,"tintColor":"#FF03A6A6","statements":[]}],"descriptionExtended":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n <!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.2//EN\"\r\n \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd\">\r\n <html>\r\n <head>\r\n <meta name=viewport content=\"width=device-width, initial-scale=1\">\r\n <meta charset=\"utf-8\" /> \r\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n <style>\r\n \tbody\r\n \t{\r\n \t\tmargin:0;\r\n \t\tpadding:0;\r\n \t\tfont-family: helvetica, arial, sans-serif;\r\n \t}\r\n \t.imgheadercontainer\r\n \t{\t\r\n \t\twidth:100%;\r\n \t}\r\n \t.imgheader\r\n \t{\r\n \t\twidth:100%;\r\n \t}\r\n \t.descriptionscontainer\r\n \t{\t\r\n \t\tpadding:10px;\r\n \t\ttext-align:justify;\r\n \t}\r\n \t.attachment_thumbnail\r\n \t{\r\n \t\twidth:20%;\r\n \t\theight:auto;\r\n \t}\r\n </style>\r\n </head>\r\n <body>\r\n \r\n <div class=\"descriptionscontainer\">\r\n <p>\n<p>Erupção benigna na pele que se caracteriza por placas eritematosas, que costumam começar no peito, costas e/ou abdômen e podem se espalhar para o resto do corpo. Pode surgir em qualquer idade, mas predomina em crianças maiores e adultos jovens.</p>\n<p>A causa é desconhecida, mas acredita-se ser devido a uma infecção viral. Não é contagiosa entre pessoas.</p>\n<p>Os sintomas iniciais são semelhantes a um resfriado comum: dor de cabeça, febre, dor de garganta e/ou congestão nasal. Segue-se o aparecimento de uma grande lesão cutânea escamosa e arredondada, que em poucos dias se estende na forma de lesões menores pelo resto do corpo. Geralmente, estas lesões provocam intensa coceira.</p>\n<p>O diagnóstico é clínico, baseado na anamnese e exame físico. Se existe dúvida quanto ao diagnóstico, pode-se complementar o estudo com exame de sangue e biopsia.</p>\n<p>O tratamento baseia-se em aliviar a coceira com anti-histamínicos e/ou loções; remédios caseiros, como banhos com água morna, podem ajudar a diminuir a coceira. O uso de fototerapia pode acelerar o desaparecimento das lesões cutâneas. Por último, empregam-se antivirais nos casos claramente associados a uma virose.</p>\n<p>Se você tem algum destes sintomas ou eles ainda não desapareceram 12 semanas após o diagnóstico, consulte um especialista.</p>\n</p>\r\n </div>\r\n <br/>\r\n <div class=\"imgheadercontainer\">\r\n <img class=\"imgheader\" src=\"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=45c9a541-dbfc-41fe-8b73-76d021b245a1&d=1596042153781&b&l=1920\"/>\r\n </div>\r\n <br/>\r\n <div class=\"descriptionscontainer\">\r\n \r\n \r\n \r\n \r\n \r\n \r\n <h4>Referências</h4>\r\n <p>\n<ol>\n\t<li>J. M Moragas. Manifestaciones cutáneas de las enfermedades internas. Interpretación de las alteraciones en la piel. Farreras Rozman. Medicina Interna. Volumen I. Duodécima edición. 707:719.</li>\n\t<li>T. J. Lwley, K.B. Yancey. Trastornos de la piel. Valoración del paciente con trastornos cutáneos. Harrison. Principios de Medicina Interna. Volumen I. Decimonovena edición. 339:352.</li>\n\t<li>I. López, C. Durán, M.M. Sáez, L. Orozco, C. Palacios, R. Ruiz. Pitiriasis rosada: un exantema que debe ser reconocido por el médico de primer contacto. Estudio de 30 casos. Acta Pediátr Mex 2014;35:289-294.</li>\n\t<li>UpToDate [Internet]. Waltham. 2017. Pityriasis rosea; [citado el 20 de julio de 2017]. Disponible en: http://www.uptodate.com/contents/pityriasis-rosea?source=search_result&search=pitiriasis+rosada&selectedTitle=1~1</li>\n</ol>\n</p>\r\n <br/>\r\n \r\n <h4>Palavras-chave</h4>\r\n <p>pitiríase rosea, vírus do herpes 7, pitiríase rósea de Gilbert, pitiríase rosea gibert</p>\r\n <br/>\r\n \r\n \r\n \r\n <br/>\r\n <br/>\r\n \r\n <p style=\"float:right;\"><b><small>\r\n \r\n Autor: Dr Maria Trabazo\r\n <br/>\r\n \r\n \r\n Revisado: 20/05/2022\r\n <br/>\r\n \r\n © TeckelMedical 2022</small></b></p>\r\n \r\n </div>\r\n \r\n </body>\r\n </html>","descriptionSummary":"<p>Erupção benigna na pele que se caracteriza por placas eritematosas, que costumam começar no peito, costas e/ou abdômen e podem se espalhar para o resto do corpo. Pode surgir em qualquer idade, mas predomina em crianças maiores e adultos jovens.</p>\n\n<p>A causa é desconhecida, mas acredita-se ser devido a uma infecção viral. Não é contagiosa entre pessoas.</p>\n\n<p>Os sintomas iniciais são semelhantes a um resfriado comum: dor de cabeça, febre, dor de garganta e/ou congestão nasal. Segue-se o aparecimento de uma grande lesão cutânea escamosa e arredondada, que em poucos dias se estende na forma de lesões menores pelo resto do corpo. Geralmente, estas lesões provocam intensa coceira.</p>\n\n<p>O diagnóstico é clínico, baseado na anamnese e exame físico. Se existe dúvida quanto ao diagnóstico, pode-se complementar o estudo com exame de sangue e biopsia.</p>\n\n<p>O tratamento baseia-se em aliviar a coceira com anti-histamínicos e/ou loções; remédios caseiros, como banhos com água morna, podem ajudar a diminuir a coceira. O uso de fototerapia pode acelerar o desaparecimento das lesões cutâneas. Por último, empregam-se antivirais nos casos claramente associados a uma virose.</p>\n\n<p>Se você tem algum destes sintomas ou eles ainda não desapareceram 12 semanas após o diagnóstico, consulte um especialista.</p>","descriptionKeywords":"pitiríase rosea, vírus do herpes 7, pitiríase rósea de Gilbert, pitiríase rosea gibert","descriptionBibliography":"<ol>\n\t<li>J. M Moragas. Manifestaciones cutáneas de las enfermedades internas. Interpretación de las alteraciones en la piel. Farreras Rozman. Medicina Interna. Volumen I. Duodécima edición. 707:719.</li>\n\t<li>T. J. Lwley, K.B. Yancey. Trastornos de la piel. Valoración del paciente con trastornos cutáneos. Harrison. Principios de Medicina Interna. Volumen I. Decimonovena edición. 339:352.</li>\n\t<li>I. López, C. Durán, M.M. Sáez, L. Orozco, C. Palacios, R. Ruiz. Pitiriasis rosada: un exantema que debe ser reconocido por el médico de primer contacto. Estudio de 30 casos. Acta Pediátr Mex 2014;35:289-294.</li>\n\t<li>UpToDate [Internet]. Waltham. 2017. Pityriasis rosea; [citado el 20 de julio de 2017]. Disponible en: http://www.uptodate.com/contents/pityriasis-rosea?source=search_result&search=pitiriasis+rosada&selectedTitle=1~1</li>\n</ol>","genderEpidemiologyDescription":"Encontrado igualmente em ambos os sexos.","ageEpidemiologyDescription":"Ocorre até a idade de 18 anos.","epidemiologyDescription":"Encontrado igualmente em ambos os sexos.\n Ocorre até a idade de 18 anos.\n","authorDescription":"Dr Maria Trabazo","copyrightDescription":"© TeckelMedical 2022","propertyValueList":[{"propertyId":"dd165ff4-e848-4b3e-b7bb-cec77117b8a1","name":"CID9","value":"696.3"},{"propertyId":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9","name":"CID9 revisado","value":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9:reviewed"},{"propertyId":"05c21681-3ff1-4c8c-bb0a-beba62984b6d","name":"CID10","value":"L42"},{"propertyId":"85c59095-eefe-469e-a6c4-faa7bf67d6a1","name":"CID10 revisado","value":"85c59095-eefe-469e-a6c4-faa7bf67d6a1:reviewed"},{"propertyId":"4a637756-3fd4-419b-9c84-31075135d8a3","name":"ICD11","value":"EA10"},{"propertyId":"f29c2d86-81fb-4ece-8375-bc1d89545af6","name":"CID11 revisado","value":"f29c2d86-81fb-4ece-8375-bc1d89545af6:reviewed"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"77252004"},{"propertyId":"b811b9b7-2aba-422b-9794-ae4633c837d9","name":"SNOMED revisado","value":"b811b9b7-2aba-422b-9794-ae4633c837d9:reviewed"}],"symptomsOrSigns":[{"statement":{"statementId":"207","description":"Você tem uma erupção cutânea?","descriptionShort":"Erupção cutânea","images":["https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=a00ba8a5-fc16-40cc-813b-f752548a93a0&d=1605264931409&b&l=1920","https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=b8027d03-fcc9-4dd0-901e-66b79f170268&d=1477638095996&b&l=1920"],"mediaFileList":[{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=a00ba8a5-fc16-40cc-813b-f752548a93a0&d=1605264931409&b&l=1920","copyright":"© Copyright TeckelMedical","type":1},{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=b8027d03-fcc9-4dd0-901e-66b79f170268&d=1477638095996&b&l=1920","copyright":"© Copyright TeckelMedical","type":1}],"questionType":0,"descriptionLarge":"Zona da pele avermelhada, com manchas e/ou borbulhas, geralmente irritada.","descriptionExtended":"Zona da pele avermelhada, com manchas e/ou borbulhas, geralmente irritada.","hasDescriptionExtended":true,"categoryIdList":[],"propertyValueList":[{"propertyId":"9732a98d-86c1-4df9-9522-bc479417e25d","name":"CID10 +Genéricos","value":"R21"},{"propertyId":"ea24aba3-468d-42ba-8cf1-c95d1322aee6","name":"CID9 + Genérico","value":"782.1"},"statementId":"d5f8e344-3c7a-491f-8f67-5e6901c4dc6b","positiveProbability":1.0,"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","lastEdited":1522923311633,"isActive":true,"obligatory":false},{"statement":{"statementId":"37","description":"Sua pele coça?","descriptionShort":"Coceira na pele","images":["https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=f39068f9-d8a6-4d07-842f-2e1216550c77&d=1563813028540&b&l=1920"],"mediaFileList":[{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=f39068f9-d8a6-4d07-842f-2e1216550c77&d=1563813028540&b&l=1920","copyright":"© Copyright TeckelMedical","description":"Comichão na pele","type":1}],"questionType":1,"descriptionLarge":"<p>Você sente formigamento e/ou coceira em todo o corpo ou em parte dele, e tem vontade de coçar para aliviar a sensação.</p>","descriptionExtended":"<p>Você sente formigamento e/ou coceira em todo o corpo ou em parte dele, e tem vontade de coçar para aliviar a sensação.</p>","hasDescriptionExtended":true,"categoryIdList":[],"propertyValueList":[{"propertyId":"9732a98d-86c1-4df9-9522-bc479417e25d","name":"CID10 +Genéricos","value":"L29.8"},{"propertyId":"ea24aba3-468d-42ba-8cf1-c95d1322aee6","name":"CID9 + Genérico","value":"698.8"},{"propertyId":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9","name":"CID9 revisado","value":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9:reviewed"},{"propertyId":"85c59095-eefe-469e-a6c4-faa7bf67d6a1","name":"CID10 revisado","value":"85c59095-eefe-469e-a6c4-faa7bf67d6a1:reviewed"},{"propertyId":"b4884c54-c88f-42f8-bf3c-adaa2e52f481","name":"CID9 + Específico","value":"698.0"},{"propertyId":"4a637756-3fd4-419b-9c84-31075135d8a3","name":"ICD11","value":"ME65.1"},{"propertyId":"1ccc2416-38f7-484c-967a-78dcf1f9bd12","name":"CID10 +Específicos","value":"L29.0"},{"propertyId":"f29c2d86-81fb-4ece-8375-bc1d89545af6","name":"CID11 revisado","value":"f29c2d86-81fb-4ece-8375-bc1d89545af6:reviewed"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"418363000"},{"propertyId":"b811b9b7-2aba-422b-9794-ae4633c837d9","name":"SNOMED revisado","value":"b811b9b7-2aba-422b-9794-ae4633c837d9:reviewed"}]},"statementId":"37","positiveProbability":0.45,"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","lastEdited":1500999357637,"isActive":true,"obligatory":false},{"statement":{"statementId":"91","description":"Você teve febre ou se sentiu febril?","descriptionShort":"Febre / Sensação de febre","images":["https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=5f620ae9-80e5-4a46-bb29-189aa45b029d&d=1604063802270&b&l=1920"],"mediaFileList":[{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=5f620ae9-80e5-4a46-bb29-189aa45b029d&d=1604063802270&b&l=1920","copyright":"© Copyright TeckelMedical","type":1}],"questionType":0,"descriptionLarge":"<p>Aumento da temperatura corporal. Quando aumenta alguns décimos acima de 37ºC é chamada de febrícula e quando ultrapassa 38ºC já é considerada febre. A pele geralmente está quente ao toque e pode ser acompanhada de outros sintomas como fraqueza, dores musculares, dores nas articulações, etc.</p>","descriptionExtended":"<p>Aumento da temperatura corporal. Quando aumenta alguns décimos acima de 37ºC é chamada de febrícula e quando ultrapassa 38ºC já é considerada febre. A pele geralmente está quente ao toque e pode ser acompanhada de outros sintomas como fraqueza, dores musculares, dores nas articulações, etc.</p>","hasDescriptionExtended":true,"categoryIdList":[],"propertyValueList":[{"propertyId":"dd165ff4-e848-4b3e-b7bb-cec77117b8a1","name":"CID9","value":"780.6"},{"propertyId":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9","name":"CID9 revisado","value":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9:reviewed"},{"propertyId":"85c59095-eefe-469e-a6c4-faa7bf67d6a1","name":"CID10 revisado","value":"85c59095-eefe-469e-a6c4-faa7bf67d6a1:reviewed"},{"propertyId":"4a637756-3fd4-419b-9c84-31075135d8a3","name":"ICD11","value":"MG26"},{"propertyId":"05c21681-3ff1-4c8c-bb0a-beba62984b6d","name":"CID10","value":"R50.9"},{"propertyId":"f29c2d86-81fb-4ece-8375-bc1d89545af6","name":"CID11 revisado","value":"f29c2d86-81fb-4ece-8375-bc1d89545af6:reviewed"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"386661006"},{"propertyId":"b811b9b7-2aba-422b-9794-ae4633c837d9","name":"SNOMED revisado","value":"b811b9b7-2aba-422b-9794-ae4633c837d9:reviewed"}]},"statementId":"91","positiveProbability":0.4,"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","lastEdited":1570016497485,"isActive":true,"obligatory":false},{"statement":{"statementId":"p10092a","description":"Você tem irritação/infamação da faringe?","descriptionShort":"Irritação/Inflamação na faringe","images":["https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=9026d2c1-fb12-4bb3-bd30-d6c7dcdd482a&d=1605264518227&b&l=1920","https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=8b5a7c25-acbd-45d3-a417-cffcdb8476dc&d=1477779428028&b&l=1920"],"mediaFileList":[{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=9026d2c1-fb12-4bb3-bd30-d6c7dcdd482a&d=1605264518227&b&l=1920","copyright":"© Copyright TeckelMedical","type":1},{"mediaURL":"https://api.mediktor.com/backoffice/downloads/File.Download?userId=04c35e41-6a8b-4541-44a3-cc20230ebdff&type=media&id=8b5a7c25-acbd-45d3-a417-cffcdb8476dc&d=1477779428028&b&l=1920","copyright":"© Copyright TeckelMedical","type":1}],"questionType":0,"descriptionLarge":"Por exemplo, como quando você está resfriado e tem dor de garganta e dificuldade para engolir.","descriptionExtended":"Por exemplo, como quando você está resfriado e tem dor de garganta e dificuldade para engolir.","hasDescriptionExtended":true,"categoryIdList":[],"propertyValueList":[{"propertyId":"dd165ff4-e848-4b3e-b7bb-cec77117b8a1","name":"CID9","value":"462"},{"propertyId":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9","name":"CID9 revisado","value":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9:reviewed"},{"propertyId":"85c59095-eefe-469e-a6c4-faa7bf67d6a1","name":"CID10 revisado","value":"85c59095-eefe-469e-a6c4-faa7bf67d6a1:reviewed"},{"propertyId":"4a637756-3fd4-419b-9c84-31075135d8a3","name":"ICD11","value":"CA02.Z"},{"propertyId":"05c21681-3ff1-4c8c-bb0a-beba62984b6d","name":"CID10","value":"J02.9"},{"propertyId":"f29c2d86-81fb-4ece-8375-bc1d89545af6","name":"CID11 revisado","value":"f29c2d86-81fb-4ece-8375-bc1d89545af6:reviewed"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"405737000"},{"propertyId":"b811b9b7-2aba-422b-9794-ae4633c837d9","name":"SNOMED revisado","value":"b811b9b7-2aba-422b-9794-ae4633c837d9:reviewed"}]},"statementId":"p10092a","positiveProbability":0.35,"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","lastEdited":1559730569538,"isActive":true,"obligatory":false}],"triggeringFactors":[{"statement":{"statementId":"p2031","description":"Você acabou de se recuperar de uma infecção viral?","descriptionShort":"Infecção viral recente","images":[],"questionType":0,"descriptionLarge":"Infecção recente causada por um vírus.","descriptionExtended":"Infecção recente causada por um vírus.","hasDescriptionExtended":true,"categoryIdList":[],"propertyValueList":[{"propertyId":"dd165ff4-e848-4b3e-b7bb-cec77117b8a1","name":"CID9","value":"790.8"},{"propertyId":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9","name":"CID9 revisado","value":"b0c0d503-cc2a-4416-a53c-e10f465d4bf9:reviewed"},{"propertyId":"85c59095-eefe-469e-a6c4-faa7bf67d6a1","name":"CID10 revisado","value":"85c59095-eefe-469e-a6c4-faa7bf67d6a1:reviewed"},{"propertyId":"4a637756-3fd4-419b-9c84-31075135d8a3","name":"ICD11","value":"1D9Z"},{"propertyId":"05c21681-3ff1-4c8c-bb0a-beba62984b6d","name":"CID10","value":"B34.9"},{"propertyId":"f29c2d86-81fb-4ece-8375-bc1d89545af6","name":"CID11 revisado","value":"f29c2d86-81fb-4ece-8375-bc1d89545af6:reviewed"},{"propertyId":"cb6e1fc1-a673-4eab-8dec-4a483a473818","name":"SNOMED","value":"34014006"},{"propertyId":"b811b9b7-2aba-422b-9794-ae4633c837d9","name":"SNOMED revisado","value":"b811b9b7-2aba-422b-9794-ae4633c837d9:reviewed"}]},"statementId":"p2031","positiveProbability":0.7,"conclusionId":"e61a5a5b-2587-48ee-af32-49331f659810","lastEdited":1497437641406,"isActive":true,"obligatory":false}],"level":0,"urgency":5,"urgencyEnum":0,"service":6,"common":false}}

Get all text from all divs with the same class name in Python Selenium

I want to get all today's big games from Bet365 (Warning its a gambling site!) but i only can get one which is the first game.
I try this but no working:
try:
driver.maximize_window()
driver.get("https://www.bet365.es/#/HO/")
driver.implicitly_wait(5)
except:
print("No se ha podido acceder a Bet365. Comprueba si la página funciona correctamente y no estas bloqueado de ella.")
try:
partidos_destacados = driver.find_element_by_class_name("fh-ParticipantFixtureTeam_TruncateName")
for i in partidos_destacados:
print(i.text)
except:
print("No se han podido leer los partidos destacados. Comprueba si ha cambiado el nombre del class en el HTML de BET365")
There are many divs with class name "fh-ParticipantFixtureTeam_TruncateName" and I need get all of this.
I encountered the error. Im using driver.find_element_by_class_name but i need use driver.find_elements_by_class_name.
This is the code fixed:
try:
driver.maximize_window()
driver.get("https://www.bet365.es/#/HO/")
driver.implicitly_wait(5)
except:
print("No se ha podido acceder a Bet365. Comprueba si la página funciona correctamente y no estas bloqueado de ella.")
try:
partidos_destacados = driver.find_elements_by_class_name("fh-ParticipantFixtureTeam_TruncateName")
for i in partidos_destacados:
print(i.text)
except:
print("No se han podido leer los partidos destacados. Comprueba si ha cambiado el nombre del class en el HTML de BET365")

While loop to get information from HTML code in python

Trying to create a code that will get reviewer's name and reviews from Booking.com.
I was able to get all the necessary URLs and isolate reviewer's name and comments from the HTML code but I'm struggling to create a while to go to the next review.
The while loop should take the reviewer's name append it to the list, move to the next name append it and so forth. I also need to the same for the comment.
When running the code nothing happens and I'm not sure where my issue is.
#Loop parameters
##HTMLs
#Booking.com URL
search_url[0] = 'https://www.booking.com/reviews/us/hotel/shore-cliff.es.html?label=gen173nr-1DEgdyZXZpZXdzKIICOOgHSDNYBGiTAogBAZgBCrgBF8gBDNgBA-gBAYgCAagCA7gC5bPZkQbAAgHSAiQzMTc3NTA4OS00OGRkLTQ5ZjYtYjBhNi1kOWEzYzZhN2QwOWXYAgTgAgE;sid=3e3ae22b47e3df3ac2590eb19d37f888;customer_type=total;hp_nav=0;old_page=0;order=featuredreviews;page=1;r_lang=all;rows=75&'
link = search_urls[0] #Just the first one to try
url = link
html = urllib.request.urlopen(url).read().decode('utf-8') #loading each search page
#Main HTML of first hotel
index=html.find('class="review_list"')
review_list_html = html[index:]
##Lists:
hotels=[]
reviewer_name=[]
review_comment=[]
#Creating counter variable
counter=0
reviewercount =0
#Main HTML of first hotel
index=html.find('class="review_list"')
review_list_html = html[index:]
reviewer_html = review_list_html[review_list_html.find('reviewer_name'):]
review_html = review_list_html[review_list_html.find('class="review_pos ">'):]
#Loop to get reviewer
while review_list_html.find('reviewer_name'):
#Get reviewer's name
#Start of reviewers name
start =reviewer_html.find('<span itemprop="name">')+22 #To ignore <span itemprop="name"> and jump right the name
start
#End of reviewers name
end =reviewer_html.find('</span>')
#Isolating reviewers name
reviewer_html=reviewer_html[start:end]
#Adding reviewer to list
reviewer_name.append(reviewer_html)
Your issue is that every next index lookup you need to start from previous index, otherwise you will create eternal loop. Generally it's more common to use HTML parsers like Beautiful Soup, but it's absolutely possible to parse this page with method you're trying to use.
We can use "reviewer_name" as main index for every review block. Starting from this index we will get indexes of "name" and </span>. Text between those indexes is reviewer's name. To parse review body we will find all indexes of "reviewBody" before index of next review block.
Full code:
from urllib.request import urlopen
link = "https://www.booking.com/reviews/us/hotel/shore-cliff.es.html"
with urlopen(link) as request:
response = request.read().decode()
reviews = []
name_pos = response.find('"reviewer_name"') # find first review
while name_pos >= 0:
name = ""
review_blocks = []
start_pos = response.find('"name"', name_pos)
end_pos = response.find("</span>", start_pos)
if end_pos > start_pos >= 0:
name = response[start_pos + 7: end_pos]
prev_name_pos = name_pos
name_pos = response.find('"reviewer_name"', name_pos + 1) # get next review
start_pos = response.find('"reviewBody"', prev_name_pos, name_pos)
while start_pos >= 0:
end_pos = response.find("</span>", start_pos)
if end_pos > start_pos >= 0:
review_blocks.append(response[start_pos + 13: end_pos])
start_pos = response.find('"reviewBody"', start_pos + 1, name_pos)
reviews.append((name, "\n".join(review_blocks)))
reviews content:
[
('Adriana',
'Nada para criticar.\n'
'Impecable lugar, habitación con vistas hermosas cualquiera sea. Camas '
'confortables, pequeña cocina completa, todo impecable.\n'
'La atención en recepción excelente, no se pierdan las cookies que convidan '
'por la tarde allí. El desayuno variado y con unos tamales exquisitos! Cerca '
'de todo.'),
('Ana', 'Todo excelente'),
('Lara',
'simplemente un poco de ruido en el tercer piso pero solo fue un poco antes '
'de las 10:00pm\n'
'realmente todo estaba excelente, ese gran detalle de el desayuno se les '
'agradece mucho.'),
('Rodrigo',
'Todo me gustó solo lo único que me hubiera gustado que también tuvieran es '
'unas chimeneas.\n'
'El hotel tiene una hermosa vista y se puede caminar y disfrutar por toda la '
'orilla de la playa hasta llegar al muelle y mas lejos si uno quiere.'),
('May', 'Me encanto q estaba abierta la piscina 👍🌊el mar expectacular'),
('Scq', 'Las vistas al Pacífico'),
('Eva', 'Desayuno\nUbicación y limpieza'),
('Marta',
'Muy buena ubicación y vistas al mar. Habitaciones modernas, amplias y con '
'cocina. Buen desayuno y hasta las 10, a diferencia de otros hoteles en los '
'que estuvimos. Personal muy amable. El chek out es a las 12 por lo que te '
'permite disfrutar de las piscina y de las vistas y paseo por la costa.'),
('Filippo',
'Habitación enorme, y muy limpio. \n'
'La habitación con vista al Ocean .... top'),
('Enrique', 'La atención del personal'),
('Lucia',
'El lugar para el desayuno es demasiado pequeño y no hay lugar suficiente '
'para sentarse\n'
'La vista, los jardines y todo el entorno son preciosos. Y es muy '
'confortable!'),
('Pablo', 'El precio.\nLa ubicación y el desayuno'),
('Walter', 'El hotel está bien, la ubicación es buena'),
('Anónimo', 'Muy bueno, el personal muy amable\nExcelente lugar muy cómodo'),
('Gonzalo', ''),
('Maria', ''),
('Rosana', ''),
('Leticia', ''),
('María', ''),
('Samantha', '')
]

Categories