I have developing a web-crawler for this web-address, and just got a problem.
What I try to do is to crawl each list of used-car stock data, and if there is an "image" data at 4th column of each data (which is pink image meaning "sold-out") in "price" tag, I will skip that list and continue to crawl next stock data.
(What I mean above is to skip the entire following code and start the next round of "for loop". The "continue" skips the only "if" function and keeps running the following code.)
Below is my code
from bs4 import BeautifulSoup
import urllib.request
URL=http://www.bobaedream.co.kr/cyber/CyberCar.php?gubun=I&page=20
res = urllib.request.urlopen(URL)
html = res.read()
soup = BeautifulSoup(html, 'html.parser')
table = soup.find('table', class_='cyber')
# 50 lists per each page
links = []
for p in range(50):
#Car_Price
car_price=table.find_all('td', class_='price')
if car_price[p].find('em').text:
car_price_confirm = car_price[p].find('em').text
elif car_price[p].find('em').find('img'):
pass
carinfo = table.find_all('td', class_='carinfo')
carinfo_title = carinfo[p].find('a', class_='title').text
links.append(carinfo[p].find('a')['href'])
print(p+1, car_price_confirm, link[p])