Ruby html href parser working slow
You are trying to parse HTML with regexes, which is widely considered to be a bad idea. For example, all these tags would have equivalent link text and target URL:

&lt;!-- "normal" --&gt;
&lt;a href="http://example.com"&gt;Link Text&lt;/a&gt;
&lt;!-- more than one space before the attribute --&gt;
&lt;a  href="http://example.com"&gt;Link Text&lt;/a&gt;
&lt;!-- tags split across multiple lines --&gt;
&lt;a
   href="http://example.com"&gt;
   Link Text
&lt;/a&gt;
&lt;!-- universal attribute "id" in front of the "href" --&gt;
&lt;a id="foo" href="http://example.com"&gt;Link Text&lt;/a&gt;
&lt;!-- different quote character --&gt;
&lt;a href='http://example.com'&gt;Link Text&lt;/a&gt;


A line-based parser will fail here, and a regex-based parser will be very difficult to write correctly. So please use an existing HTML parser. The result will be fast and elegant, but as I don't use Ruby I can't give examples.



Let's move on to coding style. You are using multiple naming styles: beginning_time and newLine. Whatever you do, be consistent, although I'd recommend snake_case for variable names.

Some of your variable names contain abbreviations where none are necessary: quote_character is probably better than qtMark, descStart would probably be better described as description_start.

You used many variables to make your regexes appear more modular, but they are not. Your regexes will become more readable if you write them down directly rather than assembling them. You could also specify them outside of your loops:



href_regex = /href="([^"]+)"/


Points to note here:


[^"]+ is generally preferable over .*?
The /m option was highly unnecessary, because you process your input line by line. So there is no way that your . could ever match a newline in your original regex. 


In your regexes, you used #{…} interpolation a lot. Strangely you didn't do any of that when assembling other strings, instead using less readable concatenation. E.g. we could rewrite

mainEntry = "original-url=\"" + source + 
"\", dest-url=\"" + dest + "\""


as

main_entry = "original-url=\"#{source}\", dest-url=\"#{dest}\""


This is still pretty unreadable because of those pesky escapes – using the alternate %Q() literal syntax we could simplify this to:

main_entry = %Q(original-url="#{source}", dest-url="#{dest}")


… and ditto in the similar cases.

A snippet like

words = desc.split(' ')
words.each { |word| occur[word] += 1 }


could be improved in two ways:


get rid of the unnecessary variables. The code is already sufficiently self-documenting with the word parameter to the block
rename occur to something sensible like word_count


You declare your source variable outside of the each_line loop. It would be better to declare your variables as close to their point of usage as possible. Furthermore, you initialize them with the empty string. I (as a Ruby newbie) would probably initialize them to nil instead. This has the further advantage that we can remove those line.include? "some string" tests which do not even guarantee that the regex will match. The  String#[Regex, capture] method returns either the string matched by that capture group, or nil – which is exactly what we want.

Don't re-open a file all the time inside a tight loop, this is quite expensive. Open the file once, write to it multiple times. This will probably remove your main performance bottleneck.

If we stuff all this advice into your code, we might end up with the following refactoring:

start_time = Time.now

file_count = 1

File.open("firstOut.txt", 'w') do |out1|
    File.open("secondOut.txt", 'w') do |out2|
        for file_name in Dir["allParts/*.dat"] do
            puts "#{file_name}#:#{file_count}"
            file_count++

            File.open(file_name, "r") do |file|
                file.each_line do |line|
                    source      = line[/#URL:(.*?)\n/, 1]
                    destination = line[/&lt;a href="([^"]+)"/, 1]

                    if (source != nil &amp;&amp; destination != nil)
                        word_count = Hash.new(0)
                        main_entry = %Q(original-url="#{source}", dest-url="#{dest}")

                        description_start = line.rindex('"&gt;')   + 2
                        description_end   = line.rindex('&lt;/a&gt;') - 1
                        description = line[description_start .. description_end]
                        if (description != nil &amp;&amp; description != "")
                            out1.write(%Q(#{main_entry}, desc="#{desc}"\n\n)) 
                            description.split(' ').each do |word|
                                word_count[word] += 1
                            end
                        else
                            out1.write(%Q(#{main_entry}\n\n)) 
                        end

                        word_count.each do |word, count|
                            out2.write(%Q(#{main_entry}, word="#{word}", count=#{count}\n\n)) 
                        end
                    end
                end
            end
        end
    end
end

puts "Time elapsed #{Time.now - start_time} seconds"


Note that this can be improved further – the high level of indentation suggests we should extract some parts as separate functions. I further want to reiterate that I'm not a proficient Rubyist, so there might be some egregious oversights in the above code.