I'm trying to click a button but its being really difficult. More precise, I want to do it for several buttons. I have tried several options but none is working properly. Here is the html code for the button:
<button class="rlg-trade__action rlg-trade__bump --bump " type="button" data-alias="bd520a66-cc88-4af8-ba92-30111bbdbd02" data-preventtext="Bumping…">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke:#6a717f;fill:none;stroke-miterlimit:10" transform="translate(.5 .5)"><path d="m12 23v-13"></path><path d="m16 14-4-4-4 4"></path><g stroke="#6a717f"><path d="m4 17h-3v-16h22v16h-3"></path><path d="m1 5h22"></path></g></g></svg>
<span>Bump</span>
</button>
And here is the code for scrapping:
trades_column = self.driver.find_element_by_css_selector('.rlg-trading__intersect') #Section where all trades are listed
trades_list = trades_column.find_elements(By.CLASS_NAME,'rlg-trade') #Search each trade element, all of them include the bump button posted above.
for trades in trades_list:
bump = trades.find_element_by_css_selector('.rlg-trade__action.rlg-trade__bump.--bump').click()
print('Trade bumped successfully!')
time.sleep(1)
self.driver.find_element_by_css_selector('i.fa').click() #This is a click in the page to exit a box that appear after the click.
Have tried by xpath, not working either. Any help would be appreciated.
Output error: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"button.rlg-trade__action.rlg-trade__bump.--bump"}
<div class="rlg-trade" data-i="0"> its every item in the trade list section rlg-trading__intersect.
<div class="col-3-3 rlg-trading__intersect">
<div class="rlg-trade" data-i="0" style="">
<header class="rlg-trade__header
">
<a href="/player/isaacdl" class="rlg-trade__user">
<div class="rlg-trade__avatar"><img loading="lazy" class="rlg-trade__avatarimage" src="/content/media/users/avatar/128px/b35468f2331659986325.png" alt="isaacdl"></div>
<div class="rlg-trade__meta">
<div class="rlg-trade__username">
isaacdl
</div>
<span class="rlg-trade__info">
<span class="rlg-trade__time">
<span>5 hours ago</span>
<span>5 hours, 20 minutes, 40 seconds ago</span>
</span>
<span class="rlg-trade__delinfo">·
This trade will be deleted in <strong class="rlg-trade__timeleft">14 days</strong> if you don't bump it.</span>
</span>
</div>
</a>
<div class="rlg-trade__platforms">
<a target="_blank" rel="noopener" class="rlg-trade__platform" style="order: 100;" href="https://steamcommunity.com/profiles/76561198120028164" onclick="event.preventDefault();phishingAware('https://steamcommunity.com/profiles/76561198120028164');">
<img class="rlg-trade__platformlogo" src="https://static.rocket-league.com/assets/b81c8860521ff08c3d8194c2eca3491c1b158f13/images/logos/windowspc_black.svg" alt="Windows PC">
<div class="rlg-trade__platformname">
<span>Add on
Steam
</span>
<span>
auchan </span>
</div>
</a>
</div>
</header>
<div class="rlg-trade__content">
<div class="rlg-trade__labels">
<div class="rlg-trade__haslabel">
Has
</div>
<div class="rlg-trade__wantslabel">
Wants
</div>
</div>
<div class="rlg-trade__items">
<div class="rlg-trade__itemshas ">
<div class="rlg-item --very-rare --hover">
<div class="rlg-item__gradient --very-rare"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/a67e907fb81451699877.png" alt="Cristiano ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Cristiano</h2>
</div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/wheels/cristiano">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=148&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
<div class="rlg-item --very-rare --hover">
<div class="rlg-item__gradient --very-rare"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/a67e907fb81451699877.png" alt="Cristiano ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Cristiano</h2>
</div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/wheels/cristiano">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=148&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
</div>
<div class="rlg-trade__wantslabel rlg-trade__wantslabelalt">
Wants
</div>
<div class="rlg-trade__itemswants ">
<div class="rlg-item --premium --hover">
<div class="rlg-item__gradient --premium"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/da6ecd87091575484054.png" alt="Credits ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Credits</h2>
</div>
<div class="rlg-item__quantity --quantity-80 --premium">
80 </div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/misc/credits">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=2615&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
<div class="rlg-item --premium --hover">
<div class="rlg-item__gradient --premium"></div>
<img loading="lazy" class="rlg-item__image" src="/content/media/items/avatar/220px/da6ecd87091575484054.png" alt="Credits ">
<div class="rlg-item__text">
<h2 class="rlg-item__name">Credits</h2>
</div>
<div class="rlg-item__quantity --quantity-80 --premium">
80 </div>
<div class="rlg-item-links">
<a class="rlg-btn-primary --small" href="/items/misc/credits">Item details</a>
<a class="rlg-btn-secondary --small" href="/trading/?filterItem=2615&filterCertification=0&filterPaint=0&filterPlatform=0&filterItemType=1">Find trades</a>
</div>
</div>
</div>
</div>
</div>
<div class="rlg-trade__actions">
<button class="rlg-trade__action rlg-trade__bump --bump " type="button" data-alias="bd520a66-cc88-4af8-ba92-30111bbdbd02" data-preventtext="Bumping…">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke:#6a717f;fill:none;stroke-miterlimit:10" transform="translate(.5 .5)"><path d="m12 23v-13"></path><path d="m16 14-4-4-4 4"></path><g stroke="#6a717f"><path d="m4 17h-3v-16h22v16h-3"></path><path d="m1 5h22"></path></g></g></svg>
<span>Bump</span>
</button>
<a class="rlg-trade__action rlg-trade__edit --edit" href="/trade/edit?trade=bd520a66-cc88-4af8-ba92-30111bbdbd02">
<svg viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="#6a717f" stroke-linecap="round" stroke-linejoin="round"><path d="m9.5.5 2 2-5 5-3 1 1-3z"></path><path d="m10.5 8.5v2a1 1 0 0 1 -1 1h-8a1 1 0 0 1 -1-1v-8a1 1 0 0 1 1-1h2" stroke="#6a717f"></path></g></svg>
<span>Edit trade</span>
</a>
<a class="rlg-trade__action rlg-trade__disable --disable" href="/functions/disableTrade.php?trade=bd520a66-cc88-4af8-ba92-30111bbdbd02" onclick="return confirm('Are you sure you want to disable this trade? This trade will be permanently removed.')">
<svg height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><g style="stroke-linecap:round;stroke-linejoin:round;stroke-width:1.2;fill:none;stroke:#6a717f;stroke-miterlimit:10"><path d="m20.3 4.7-15.6 15.6"></path><circle cx="12.5" cy="12.5" r="11"></circle></g></svg> <span>Disable trade</span>
</a>
<a href="/trade/bd520a66-cc88-4af8-ba92-30111bbdbd02" class="rlg-trade__action --comments">
<svg viewBox="0 0 18 21" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="#545454" stroke-linecap="round" stroke-linejoin="round"><path d="m1.421053 1.421053h15.157895v18.526316h-15.157895z"></path><path d="m4.789474 4.789474h8.421053v5.052632h-8.421053z"></path><path d="m4.789474 13.210526h8.421052"></path><path d="m4.789474 16.578947h8.421052"></path></g></svg>
<span>Comments</span>
</a>
</div>
<div class="rlg-trade__note">
Have 2x of them. Please fast. </div>
<button class="rlg-trade__noteexpand" style="display: none;">Show full trade description</button>
</div>
<div class="rlg-trade rlg-trade-placeholder" data-i="1" style="height: 323px; box-shadow: none;"></div>
<div class="rlg-trade rlg-trade-placeholder" data-i="2" style="height: 323px; box-shadow: none;"></div>
<div class="rlg-trade rlg-trade-placeholder" data-i="3" style="height: 323px; box-shadow: none;"></div>
</div>
Try use following xpath to click on the element.
for trades in trades_list:
trades.find_element(By.XPATH,'.//button[.//span[text()="Bump"]]').click()
print('Trade bumped successfully!')
time.sleep(1)
I am facing an issue in python/selenium, in which I can't get, how to use Script for toast messages, that are in the same function. The function has the same locator. How can I use the same locator for two messages?
**Here is the javascript **
}, function(data, status) {
if (data.status == "OK") {
if (data.statusCode == 1){
var message = data.response;
showToast(message);
} else {
var error = data.responseMessage;
swal(error, "", "error");
}
}else {
var error = data.response;
showToast(error);
}
});
});
function showToast(content){
$("#customtoast").addClass("display");
$("#customtoast").html(content);
setTimeout(function() {
$("#customtoast").removeClass("display");
location.reload();
}, 2000);
}
** Now I want to locate separately for error and for success via the selenium/python**
Here is my html code...
<form class="new-added-form" id="addStudentForm">
<div class="row">
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="firstname" id="firstname">
<span class="highlight"></span>
<label>First Name</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="lastname" id="lastname">
<span class="highlight"></span>
<label>Last Name</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="age" id="age">
<span class="highlight"></span>
<label>Age</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<label>Date Of Birth *</label>
<input type="date" class="form-control air-datepicker border-0" data-position='bottom right' name="dob" id="dob">
<i class="far fa-calendar-alt"></i>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="email" id="email">
<span class="highlight"></span>
<label>Email</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="permitno" id="permitno">
<span class="highlight"></span>
<label>Permit number</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="nationality" id="nationality">
<span class="highlight"></span>
<label>Nationality</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="phone" id="contactno" maxlength="10">
<span class="highlight"></span>
<label>Contact Number</label>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 form-group">
<div class="floating-label">
<input class="floating-input" type="text" placeholder=" " name="address" id="address">
<span class="highlight"></span>
<label>Address</label>
</div>
</div>
<div class="col-12 form-group mg-t-8">
<button type="button" class="btn-fill-lg btn-gradient-yellow btn-hover-bluedark" id="save">Save</button>
<button type="reset" class="btn-fill-lg bg-blue-dark btn-hover-yellow">Reset</button>
</div>
</div>
</form>
<!-- Custom toast/ snackbar -->
<div id="customtoast"> </div>
I want to know the automation script for this.
For the life of me I can get chromedriver to click all these checkboxes. Either its not found or interactable.
<form class="step__form step__block" action="creation-full/step/legal-and-opt-ins" method="post" id="flow-form" enctype="multipart/form-data" novalidate="">
<input type="hidden" name="csrftoken" id="flow-csrftoken" value="52d14a6a-69d7-4c06-bbeb-3418c331892e">
<label class="step__field--label step__form__block">
<input class="step__checkbox" value="true" id="capture-opt-in-third-party-news-special-offers" data-capture-id="opt-in-third-party-news-special-offers" name="opt-in-third-party-news-special-offers" type="checkbox">
<input type="hidden" name="opt-in-third-party-news-special-offers" value="false"> <span class="step__field__indicator--checkbox"> <svg class="svg-inline--fa fa-check fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg><!-- <i class="far fa-check"></i> --> </span> <span class="step__field--label__text">Account email will receive carefully selected news, event information and special offers about third-party products and services.</span> </label>
<div class="step__legal-checkboxes step__form__block" id="legal-checkboxes">
<input type="hidden" name="tou-agreements-implicit" value="08b946df-660a-40e4-a072-1fbde65173b1;209144" data-capture-id="tou-agreements-implicit" checked="">
<input type="hidden" name="tou-agreements-implicit" value="966f03a4-29e1-440c-b142-e54ee091e52d;93047" data-capture-id="tou-agreements-implicit" checked="">
<input type="hidden" name="tou-agreements-implicit" value="cd5930c0-2784-420c-a23d-1e0d6ff8599b;110052" data-capture-id="tou-agreements-implicit" checked="">
<label class="step__field--label step__form__block">
<input class="step__checkbox" value="41e60b3d-244d-4776-be75-e2c6b3eba9a3;187105" data-capture-id="tou-agreements-implicit" name="tou-agreements-implicit" type="checkbox" checked="">
<input type="hidden" name="tou-agreements-implicit" value=""> <span class="step__field__indicator--checkbox"> <svg class="svg-inline--fa fa-check fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="check" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"></path></svg><!-- <i class="far fa-check"></i> --> </span> <span class="step__field--label__text">I have reviewed and understand the Privacy Policy. For more information about how we use information and your rights to object, see our Blizzard Entertainment® Privacy Policy <svg class="svg-inline--fa fa-external-link fa-w-16" aria-hidden="true" focusable="false" data-prefix="far" data-icon="external-link" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M497.6,0,334.4.17A14.4,14.4,0,0,0,320,14.57V47.88a14.4,14.4,0,0,0,14.69,14.4l73.63-2.72,2.06,2.06L131.52,340.49a12,12,0,0,0,0,17l23,23a12,12,0,0,0,17,0L450.38,101.62l2.06,2.06-2.72,73.63A14.4,14.4,0,0,0,464.12,192h33.31a14.4,14.4,0,0,0,14.4-14.4L512,14.4A14.4,14.4,0,0,0,497.6,0ZM432,288H416a16,16,0,0,0-16,16V458a6,6,0,0,1-6,6H54a6,6,0,0,1-6-6V118a6,6,0,0,1,6-6H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V304A16,16,0,0,0,432,288Z"></path></svg><!-- <i class="far fa-external-link"></i> --> </span> </label>
</div>
<div class="step__legal-summary step__block end">
<div class="step__legal-summary__links step__block" id="legal-summary-links"> La La La </div>
</div>
<div class="step__button-container step__block end">
<button type="submit" class="step__button step__button--primary" id="flow-form-submit-btn">Continue</button>
</div>
any help will be appriciated. thanks
You can use this id capture-opt-in-third-party-news-special-offers which is unique in nature.
If python is your binding language, then this should work :
driver.find_element_by_css_selector("#legal-checkboxes label input").click()
or if it needs explicit waits :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(driver, 50)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#legal-checkboxes label input"))).click()
or if both of them do not work, try JS :-
check_box = driver.find_element_by_css_selector("#legal-checkboxes label input")
driver.execute_script("arguments[0].click();", check_box)
I would like to be able to click on any part of a row that meets 2 criteria:
timeslot that I set (ie 5:30 - 6:30 pm)
can filter based on value Co-Ed or Women's Only
Unsure of how to filter these values. I though maybe searching the values of the row list
timeslot = driver.find_elements_by_class_name("row.c-schedule-calendar__class-schedule-listitem-wrapper.c-schedule-calendar__workout-schedule-list-item")
Below is the html code
<li tabindex="0" class="row c-schedule-calendar__class-schedule-listitem-wrapper c-schedule-calendar__workout-schedule-list-item" data-index="22" data-workout-id="156986" data-club-id="204">
<div class="col-md-12 col-lg-2 time-duration clickable js-single-class-list-item">
<span class="js-class-time">7:45 pm</span> <span class="dot-separator">-</span> <span class="js-class-duration">8:45 pm</span>
</div>
<div class="col-md-12 col-lg-10">
<div class="row">
<div class="col-8 clickable js-single-class-list-item">
<div class="row">
<div class="col-md-12 col-lg-6">
<div class="class-name"><span class="js-class-name">General Workout Area</span></div>
<div class="class-short-info">
<span class="js-class-type">Co-ed</span>
</div>
</div>
<div class="col-md-12 col-lg-6">
<div class="class-address-wrapper">
<span class="class-address">
<svg viewBox="0 0 48 48" class="c-search-class-filter--location__pin-icon">
<use xlink:href="/etc.clientlibs/goodlife/clientlibs/clientlib-site/resources/images/icons.svg#ic_pin_default"></use>
</svg> Cambridge Hespeler And Eagle
</span>
</div>
</div>
</div>
</div>
<div class="col-4 c-schedule-calendar__cta-container">
<div class="js-class-action-container">
<button class="c-btn-outlined class-action" data-class-action="book-class" data-class-action-step="class-action-confirmation" data-workout-id="156986" data-club-id="204" data-waitlistable="false"><span class="c-btn__label">Book</span></button>
</div>
<div class="available-spots">
<div class="js-available-spots-container">
2 spots left
</div>
</div>
</div>
</div>
</div></li>
time_range = "5:30 pm - 6:30 pm"
category = "Co-Ed"
"//li[descendant::text()='{}' and descendant::span[text()='{}'] and descendant::span[text()='{}']]".format(time_range.split(' - ')[0],time_range.split(' - ')[1], category)
This xpath should work, so instead of searching by class element use
driver.find_element_by_xpath("//li[descendant::text()='{}' and descendant::span[text()='{}'] and descendant::span[text()='{}']]".format(time_range.split(' - ')[0],time_range.split(' - ')[1], category)).click()
Problem Introduction
Language version: Python 3.8
Operating System: Windows 10
Other relevant software: Jupyter notebook and html-requests
Context:
I have been following along with this tutorial to scrape stackoverflow for questions. My goal is to extract the answers (from the url of the question) and who answered it. However, I am having difficulty determining what classes/id's to search for in the html of a question
Things I have tried:
I have attempted searching under ('.container') for things like ('.post-layout'), '.mb0', '#answers', and'#answers-headers' with marginal, cluttered, success.
An excerpt from the code I am using to parse the pages(not the questions) here is the github link:
def parse_tagged_page(html):
question_summaries = html.find(".question-summary")
key_names = ['question', 'votes', 'tags']
classes_needed = ['.question-hyperlink', '.vote', '.tags']
datas = []
for q_el in question_summaries:
question_data = {}
for i, _class in enumerate(classes_needed):
sub_el = q_el.find(_class, first=True)
keyname = key_names[i]
question_data[keyname] = clean_scraped_data(sub_el.text, keyname=keyname)
datas.append(question_data)
return datas
An example of the html code I am looking for is below.
html code on this question:
<div id="answers">
<a name="tab-top"></a>
<div id="answers-header">
<div class="answers-subheader grid ai-center mb8">
<div class="grid--cell fl1">
<h2 class="mb0" data-answercount="13">
13 Answers
<span style="display:none;" itemprop="answerCount">13</span>
</h2>
</div>
<div class="grid--cell">
<div class=" grid s-btn-group js-filter-btn">
<a class="grid--cell s-btn s-btn__muted s-btn__outlined" href="/questions/19254583/how-do-i-host-multiple-node-js-sites-on-the-same-ip-server-with-different-domain?answertab=active#tab-top" data-nav-xhref="" title="Answers with the latest activity first" data-value="active" data-shortcut="A">
Active</a>
<a class="grid--cell s-btn s-btn__muted s-btn__outlined" href="/questions/19254583/how-do-i-host-multiple-node-js-sites-on-the-same-ip-server-with-different-domain?answertab=oldest#tab-top" data-nav-xhref="" title="Answers in the order they were provided" data-value="oldest" data-shortcut="O">
Oldest</a>
<a class="youarehere is-selected grid--cell s-btn s-btn__muted s-btn__outlined" href="/questions/19254583/how-do-i-host-multiple-node-js-sites-on-the-same-ip-server-with-different-domain?answertab=votes#tab-top" data-nav-xhref="" title="Answers with the highest score first" data-value="votes" data-shortcut="V">
Votes</a>
</div>
</div>
</div>
</div>
<a name="19254824"></a>
<div id="answer-19254824" class="answer accepted-answer" data-answerid="19254824" itemprop="acceptedAnswer" itemscope="" itemtype="http://schema.org/Answer">
<div class="post-layout">
<div class="votecell post-layout--left">
<div class="js-voting-container grid fd-column ai-stretch gs4 fc-black-200" data-post-id="19254824">
<button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary" aria-describedby="--stacks-s-tooltip-zxmm3912"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button><div id="--stacks-s-tooltip-zxmm3912" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is useful<div class="s-popover--arrow"></div></div>
<div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="83">83</div>
<button class="js-vote-down-btn grid--cell s-btn s-btn__unset c-pointer" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary" aria-describedby="--stacks-s-tooltip-waz8801n"><svg aria-hidden="true" class="m0 svg-icon iconArrowDownLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 10h32L18 26 2 10z"></path></svg></button><div id="--stacks-s-tooltip-waz8801n" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">This answer is not useful<div class="s-popover--arrow"></div></div>
<div class="js-accepted-answer-indicator grid--cell fc-green-500 ta-center py4" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted">
<svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="M6 14l8 8L30 6v8L14 30l-8-8v-8z"></path></svg>
</div>
<a class="js-post-issue grid--cell s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/19254824/timeline" data-shortcut="T" data-controller="s-tooltip" data-s-tooltip-placement="right" aria-label="Timeline" aria-describedby="--stacks-s-tooltip-djt8qt69"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 113.73 6.77L8.2 14.3A6 6 0 105 9l3.01-.01-4 4-4-4h3L3 9zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10V5z"></path></svg></a><div id="--stacks-s-tooltip-djt8qt69" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Show activity on this post.<div class="s-popover--arrow"></div></div>
</div>
</div>
<div class="answercell post-layout--right">
<div class="s-prose js-post-body" itemprop="text">
<p>Choose one of:</p>
<ul>
<li>Use some other server (like nginx) as a reverse proxy.</li>
<li>Use node-http-proxy as a reverse proxy.</li>
<li>Use the vhost middleware if each domain can be served from the same Connect/Express codebase and node.js instance.</li>
</ul>
</div>
<div class="mt24">
<div class="grid fw-wrap ai-start jc-end gs8 gsy">
<time itemprop="dateCreated" datetime="2013-10-08T17:53:13"></time>
<div class="grid--cell mr16" style="flex: 1 1 100px;">
<div class="post-menu">
share<div class="s-popover z-dropdown" style="width: unset; max-width: 28em;" id="se-share-sheet-1"><div class="s-popover--arrow"></div><div><span class="js-title fw-bold">Share a link to this answer</span> <span class="js-subtitle">(includes your user id)</span></div><div class="my8"><input type="text" class="js-input s-input wmn3 sm:wmn-initial" readonly=""></div><div class="d-flex jc-space-between mbn4"><button class="js-copy-link-btn s-btn s-btn__link">Copy link</button>CC BY-SA 3.0<div class="js-social-container"></div></div></div>
<span class="lsep">|</span>
edit
<span class="lsep">|</span>
<button id="btnFollowPost-19254824" class="s-btn s-btn__link fc-black-400 h:fc-black-700 pb2 js-follow-post js-follow-answer js-gps-track" role="button" data-gps-track="post.click({ item: 14, priv: -1, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" aria-describedby="--stacks-s-tooltip-nb9azr0k">
follow
</button><div id="--stacks-s-tooltip-nb9azr0k" class="s-popover s-popover__tooltip pe-none" aria-hidden="true" role="tooltip">Follow this answer to receive notifications<div class="s-popover--arrow"></div></div>
<span class="lsep">|</span>
</div>
</div>
<div class="post-signature grid--cell fl0">
<div class="user-info user-hover">
<div class="user-action-time">
edited <span title="2017-05-23 11:33:25Z" class="relativetime">May 23 '17 at 11:33</span>
</div>
<div class="user-gravatar32">
<div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/a007be5a61f6aa8f3e85ae2fc18dd66e?s=32&d=identicon&r=PG" alt="" width="32" height="32" class="bar-sm"></div>
</div>
<div class="user-details">
Community<span class="mod-flair " title="moderator">♦</span>
<div class="-flair">
<span class="reputation-score" title="reputation score " dir="ltr">1</span><span title="1 silver badge" aria-hidden="true"><span class="badge2"></span><span class="badgecount">1</span></span><span class="v-visible-sr">1 silver badge</span>
</div>
</div>
</div> </div>
<div class="post-signature grid--cell fl0">
<div class="user-info user-hover">
<div class="user-action-time">
answered <span title="2013-10-08 17:53:13Z" class="relativetime">Oct 8 '13 at 17:53</span>
</div>
<div class="user-gravatar32">
<div class="gravatar-wrapper-32"><img src="https://i.stack.imgur.com/eLXTL.jpg?s=32&g=1" alt="" width="32" height="32" class="bar-sm"></div>
</div>
<div class="user-details" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
josh3736<span class="d-none" itemprop="name">josh3736</span>
<div class="-flair">
<span class="reputation-score" title="reputation score 119,818" dir="ltr">120k</span><span title="24 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">24</span></span><span class="v-visible-sr">24 gold badges</span><span title="198 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">198</span></span><span class="v-visible-sr">198 silver badges</span><span title="245 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">245</span></span><span class="v-visible-sr">245 bronze badges</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="post-layout--right">
<div id="comments-19254824" class="comments js-comments-container bt bc-black-2 mt12 " data-post-id="19254824" data-min-length="15">
<ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">
<li id="comment-45028507" class="comment js-comment " data-comment-id="45028507">
<div class="js-comment-actions comment-actions">
<div class="comment-score js-comment-edit-hide">
<span title="number of 'useful comment' votes received" class="cool">3</span>
</div>
</div>
<div class="comment-text js-comment-text-and-form">
<div class="comment-body js-comment-edit-hide">
<span class="comment-copy">that's a very good and brief list of the options I've read elsewhere. Do you happen to know for each of these solutions which processes would need to be restarted when a new domain is added? For 1) none. For 2) only the node-http-proxy. For 3) the entire thread of all sites would need to be restarted. Is this correct?</span>
– Flion
<span class="comment-date" dir="ltr"><a class="comment-link" href="#comment45028507_19254824"><span title="2015-02-05 10:48:37Z, License: CC BY-SA 3.0" class="relativetime-clean">Feb 5 '15 at 10:48</span></a></span>
</div>
</div>
</li>
<li id="comment-45045094" class="comment js-comment " data-comment-id="45045094">
<div class="js-comment-actions comment-actions">
<div class="comment-score js-comment-edit-hide">
<span title="number of 'useful comment' votes received" class="cool">1</span>
</div>
</div>
<div class="comment-text js-comment-text-and-form">
<div class="comment-body js-comment-edit-hide">
<span class="comment-copy">#Flion: You could write the node-based proxies in such a way that you could reload the domain configuration without requiring a process restart. It really depends on your app's exact requirements.</span>
– josh3736
<span class="comment-date" dir="ltr"><a class="comment-link" href="#comment45045094_19254824"><span title="2015-02-05 17:50:17Z, License: CC BY-SA 3.0" class="relativetime-clean">Feb 5 '15 at 17:50</span></a></span>
</div>
</div>
</li>
<li id="comment-107457123" class="comment js-comment " data-comment-id="107457123">
<div class="js-comment-actions comment-actions">
<div class="comment-score js-comment-edit-hide">
</div>
</div>
<div class="comment-text js-comment-text-and-form">
<div class="comment-body js-comment-edit-hide">
<span class="comment-copy">Not what was asked.</span>
– Patrick Sturm
<span class="comment-date" dir="ltr"><a class="comment-link" href="#comment107457123_19254824"><span title="2020-03-18 07:47:44Z, License: CC BY-SA 4.0" class="relativetime-clean">Mar 18 at 7:47</span></a></span>
</div>
</div>
</li>
</ul>
</div>
<div id="comments-link-19254824" data-rep="50" data-reg="true">
<a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">add a comment</a>
<span class="js-link-separator dno"> | </span>
<a class="js-show-link comments-link dno" title="expand to show all comments on this post" href="#" onclick="" role="button"></a>
</div>
</div>
</div>
</div>
You should look for .answercell class