Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:14:30+00:00 2026-05-31T03:14:30+00:00

On the page I have the following HTML source: <div class=date>date1</div> <div class=company><div class=time>time1</div>

  • 0

On the page I have the following HTML source:

<div class="date">date1</div>

<div class="company"><div class="time">time1</div>
<a href="company_link1">company_name1</a></div>

<div class="company"><div class="time">time2</div>
<a href="company_link2">company_name2</a></div>

<div class="date">date2</div>
<div class="company"><div class="time">time3</div>
<a href="company_link3">company_name3</a></div>

... etc. 

I need to receive at final stage the following array:

array = [ [date, time1, company_name1, company_link1], [date, time2, company_name2, company_link2], [date2, time3, company_name3, company_link3], … ]

The problem is that div “class=company” doesn’t have the date, so I need to parse the correct dates and add each date to all items (time, company name, company link).

Thanks a lot for your help, I’m a newbie to Ruby.

PS: I need to use mechanize cause my page can be retrieved only via log-in.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:14:31+00:00Added an answer on May 31, 2026 at 3:14 am

    Hmm, your date2 div isn’t closed properly but maybe something like:

    doc.css('.company').map{|x| [x.at('./preceding-sibling::div[@class="date"][1]').text, x.at('.time').text, x.at('a').text, x.at('a')[:href]]}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my html page, I have the following: <div id=rub> Select at least one
I have a layout page with the following _app.cshtml <div id=top_right> @{ Html.Partial(_LogOnPartial); }
I have the following page : <html> <head> <link type=text/css href=css/smoothness/jquery-ui-1.8.14.custom.css rel=stylesheet /> <style
I have the following HTML Code <%@ Page Language=C# %> <html> <head> <title></title> </head>
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
i have following code to show div on page <div id=all_users> <div id=user11 userid=11
so i have the two following iframe codes: <iframe title=YouTube video player class=youtube-player type=text/html
I have the following in web layout (master page): @(Html.Telerik().ScriptRegistrar() .DefaultGroup(group => group .DefaultPath(~/Assets/telerikaspnetmvc/2011.2.712/Scripts/)
What is the best method of doing the following: I have Page A with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.